/* IELTS Writing Tutor Pro - Public Styles */

:root {
    --iwptp-primary-color: #005A9C; /* A professional blue */
    --iwptp-light-gray: #f4f4f4;
    --iwptp-medium-gray: #ddd;
    --iwptp-dark-gray: #555;
    --iwptp-error-color: #D63638;
    --iwptp-success-color: #28a745; /* Added success color */
}

.iwptp-container {
    max-width: 800px;
    margin: 20px auto;
    padding: 25px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    border: 1px solid var(--iwptp-medium-gray);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* Header/Branding */
.iwptp-header {
    text-align: center;
    border-bottom: 2px solid var(--iwptp-light-gray);
    padding-bottom: 20px;
    margin-bottom: 25px;
}
.iwptp-logo {
    max-height: 80px;
    width: auto;
    margin-bottom: 10px;
}
.iwptp-header h2 {
    font-size: 24px;
    color: #333;
    margin: 0;
}

/* Form Fields */
.iwptp-field-group {
    margin-bottom: 20px;
}
.iwptp-field-group label {
    display: block;
    font-weight: 600;
    color: var(--iwptp-dark-gray);
    margin-bottom: 8px;
    font-size: 16px;
}
.iwptp-field-group input[type="text"],
.iwptp-field-group input[type="file"], /* Added file for consistency */
.iwptp-field-group select,
.iwptp-field-group textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--iwptp-medium-gray);
    border-radius: 6px;
    font-size: 15px;
    box-sizing: border-box; /* Important */
    transition: border-color 0.2s, box-shadow 0.2s;
}
.iwptp-field-group input[type="text"]:focus,
.iwptp-field-group input[type="file"]:focus,
.iwptp-field-group select:focus,
.iwptp-field-group textarea:focus {
    border-color: var(--iwptp-primary-color);
    box-shadow: 0 0 0 2px rgba(0, 90, 156, 0.2);
    outline: none;
}
.iwptp-field-group p.description {
    font-size: 13px;
    color: #777;
    margin: 6px 0 0 0;
    font-style: italic;
}

/* --- Buttons --- */
.iwptp-button {
    background: var(--iwptp-primary-color);
    color: #fff;
    font-size: 16px;
    font-weight: 600;
    padding: 12px 24px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
    text-decoration: none;
    display: inline-block;
}
.iwptp-button:hover {
    background: #004a80;
}
.iwptp-button:active {
    transform: translateY(1px);
}
.iwptp-button:disabled {
    background: #a0a0a0;
    cursor: not-allowed;
}

.iwptp-button-secondary {
    background: var(--iwptp-dark-gray);
}
.iwptp-button-secondary:hover {
    background: #333;
}

/* Small buttons for the header */
.iwptp-button-small {
    padding: 6px 12px;
    font-size: 13px;
    font-weight: 500;
}

/* 'Copied' state for copy button */
.iwptp-button-copied {
    background-color: var(--iwptp-success-color) !important;
}


/* --- Results Area --- */
#iwptp-results-wrapper {
    margin-top: 30px;
    border-top: 2px solid var(--iwptp-light-gray);
    padding-top: 20px;
}

/* Updated: Flexbox layout for the result header */
.iwptp-result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    flex-wrap: wrap; /* Allow wrapping on small screens */
    gap: 10px;
}

/* Button group in header */
.iwptp-button-group {
    display: flex;
    flex-wrap: wrap; /* Allow buttons to wrap */
    gap: 8px;
}

#iwptp-results-wrapper h3 {
    font-size: 22px;
    color: #333;
    margin: 0; /* Remove default margin */
}

#iwptp-results-content {
    background: var(--iwptp-light-gray);
    border: 1px solid var(--iwptp-medium-gray);
    border-radius: 6px;
    padding: 20px;
    font-size: 15px;
    line-height: 1.6;
}

/* --- Feedback Formatting (from Markdown) --- */
#iwptp-results-content h1,
#iwptp-results-content h2,
#iwptp-results-content h3,
#iwptp-results-content h4 {
    color: #333;
    margin-top: 20px;
}
#iwptp-results-content ul,
#iwptp-results-content ol {
    margin-left: 20px;
    padding-left: 10px;
}
#iwptp-results-content li {
    margin-bottom: 8px;
}
#iwptp-results-content hr {
    border: 0;
    border-top: 1px solid var(--iwptp-medium-gray);
    margin: 20px 0;
}
#iwptp-results-content code {
    background: #e9e9e9;
    padding: 2px 5px;
    border-radius: 4px;
    font-family: monospace;
}
#iwptp-results-content pre {
    background: #e9e9e9;
    padding: 10px;
    border-radius: 4px;
    overflow-x: auto;
}
#iwptp-results-content blockquote {
    border-left: 4px solid var(--iwptp-medium-gray);
    padding-left: 10px;
    color: #555;
    font-style: italic;
    margin-left: 0;
}
#iwptp-results-content table {
    border-collapse: collapse;
    width: 100%;
}
#iwptp-results-content th,
#iwptp-results-content td {
    border: 1px solid var(--iwptp-medium-gray);
    padding: 8px;
    text-align: left;
}
#iwptp-results-content th {
    background-color: #e9e9e9;
}


/* --- Loading and Error Messages --- */
.iwptp-loading {
    color: var(--iwptp-dark-gray);
    font-weight: 600;
}
.iwptp-error {
    color: var(--iwptp-error-color);
    background: #fff0f0;
    border: 1px solid var(--iwptp-error-color);
    padding: 15px;
    border-radius: 6px;
}

/* --- *** NEW: Edit Area Styles *** --- */
#iwptp-edit-feedback-area {
    width: 100%;
    min-height: 400px;
    padding: 15px;
    border: 1px solid var(--iwptp-medium-gray);
    border-radius: 6px;
    font-family: monospace;
    font-size: 14px;
    line-height: 1.5;
    box-sizing: border-box; /* Ensure padding doesn't break layout */
    transition: border-color 0.2s, box-shadow 0.2s;
}
#iwptp-edit-feedback-area:focus {
    border-color: var(--iwptp-primary-color);
    box-shadow: 0 0 0 2px rgba(0, 90, 156, 0.2);
    outline: none;
}

#iwptp-save-edit-button {
    margin-top: 10px;
    background-color: var(--iwptp-success-color);
    font-size: 15px;
}
#iwptp-save-edit-button:hover {
    background-color: #218838;
}

/* Style for the "Edit" button when active */
#iwptp-edit-feedback.iwptp-button-active {
    background-color: var(--iwptp-error-color);
}