/* ===========================
   Reset & Base Styles
   =========================== */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
        'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    background-color: #f0f2f5;
    color: #1a1a2e;
    line-height: 1.6;
    min-height: 100vh;
}

/* ===========================
   App Container
   =========================== */

.app-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ===========================
   Header
   =========================== */

.app-header {
    background: white;
    padding: 16px 40px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #e8eaed;
    flex-shrink: 0;
}

.header-brand {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.app-header h1 {
    color: #2563eb;
    font-size: 26px;
    font-weight: 600;
    line-height: 1.2;
}

.header-tagline {
    color: #6b7280;
    font-size: 14px;
    font-weight: 400;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Quota Badge */
.quota-badge {
    background: #d1fae5;
    color: #065f46;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
}

.quota-badge.low {
    background: #fef3c7;
    color: #92400e;
}

.quota-badge.critical {
    background: #fee2e2;
    color: #991b1b;
}

/* Login Button */
.btn-login {
    background: white;
    color: #2563eb;
    border: 2px solid #2563eb;
    padding: 8px 20px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-login:hover {
    background: #eff6ff;
}

/* ===========================
   Main Content
   =========================== */

.main-content {
    flex: 1;
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
    padding: 24px 40px;
    display: flex;
    flex-direction: column;
}

/* ===========================
   Tone Tabs
   =========================== */

.tone-tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid #e5e7eb;
    margin-bottom: 20px;
    flex-shrink: 0;
}

.tone-tab {
    background: none;
    border: none;
    padding: 12px 24px;
    font-size: 15px;
    font-weight: 500;
    color: #6b7280;
    cursor: pointer;
    position: relative;
    transition: color 0.2s;
}

.tone-tab:hover {
    color: #374151;
}

.tone-tab.active {
    color: #1a1a2e;
    font-weight: 600;
}

.tone-tab.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    right: 0;
    height: 2px;
    background: #2563eb;
}

/* ===========================
   Editor Container
   =========================== */

.editor-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin-bottom: 20px;
    flex: 1;
    min-height: calc(72vh - 100px);
}

.editor-panel {
    background: white;
    border-radius: 12px;
    border: 1px solid #e5e7eb;
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 500px;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid #f3f4f6;
}

.panel-title {
    font-size: 15px;
    font-weight: 600;
    color: #374151;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.success-check {
    color: #10b981;
    font-weight: bold;
}

.success-check.hidden {
    display: none;
}

.btn-icon {
    background: none;
    border: none;
    color: #9ca3af;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-icon:hover {
    color: #6b7280;
    background: #f3f4f6;
}

/* Editor Textarea */
.editor-textarea {
    flex: 1;
    width: 100%;
    padding: 20px;
    border: none;
    font-size: 16px;
    font-family: inherit;
    line-height: 1.7;
    resize: none;
    background: transparent;
    min-height: 0;
}

.editor-textarea:focus {
    outline: none;
}

.editor-textarea::placeholder {
    color: #9ca3af;
}

/* Editor Output */
.editor-output {
    flex: 1;
    padding: 20px;
    font-size: 16px;
    line-height: 1.7;
    color: #1a1a2e;
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow-y: auto;
    min-height: 0;
}

.editor-output:empty::before {
    content: attr(placeholder);
    color: #9ca3af;
}

/* Panel Footer */
.panel-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    border-top: 1px solid #f3f4f6;
}

.char-counter {
    font-size: 12px;
    color: #9ca3af;
    margin-left: auto;
}

.char-counter.warning {
    color: #f59e0b;
}

.char-counter.error {
    color: #ef4444;
}

.validation-error {
    font-size: 13px;
    color: #ef4444;
    font-weight: 500;
}

/* Output Actions */
.output-actions {
    justify-content: flex-end;
    gap: 12px;
}

.btn-copy,
.btn-export {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-copy {
    background: #2563eb;
    color: white;
    border: none;
}

.btn-copy:hover:not(:disabled) {
    background: #1d4ed8;
}

.btn-copy:disabled {
    background: #93c5fd;
    cursor: not-allowed;
}

.btn-export {
    background: white;
    color: #374151;
    border: 1px solid #e5e7eb;
}

.btn-export:hover:not(:disabled) {
    background: #f9fafb;
    border-color: #d1d5db;
}

.btn-export:disabled {
    color: #9ca3af;
    cursor: not-allowed;
}

/* ===========================
   Action Container
   =========================== */

.action-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    flex-shrink: 0;
}

.btn-rephrase {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 16px 48px;
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: white;
    border: none;
    border-radius: 50px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.3);
}

.btn-rephrase:hover:not(:disabled) {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    box-shadow: 0 6px 20px rgba(37, 99, 235, 0.4);
    transform: translateY(-1px);
}

.btn-rephrase:disabled {
    background: #93c5fd;
    box-shadow: none;
    cursor: not-allowed;
}

.btn-sparkle {
    font-size: 18px;
}

/* Loading Indicator */
.loading-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #6b7280;
    font-size: 14px;
}

.loading-indicator.hidden {
    display: none;
}

.loading-spinner {
    animation: spin 2s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* ===========================
   Warnings Container
   =========================== */

.warnings-container {
    background: #fef3c7;
    border-left: 4px solid #f59e0b;
    padding: 16px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.warnings-container.hidden {
    display: none;
}

.warning-item {
    display: flex;
    align-items: flex-start;
    margin-bottom: 8px;
}

.warning-item:last-child {
    margin-bottom: 0;
}

.warning-icon {
    color: #f59e0b;
    margin-right: 8px;
    font-weight: bold;
}

.warning-message {
    color: #92400e;
    font-size: 14px;
}

/* ===========================
   Footer
   =========================== */

.app-footer {
    text-align: center;
    padding: 16px 20px;
    color: #9ca3af;
    font-size: 13px;
    background: #f0f2f5;
    flex-shrink: 0;
}

.app-footer p {
    margin: 0;
}

/* ===========================
   Contact Us Button (Header)
   =========================== */

.btn-contact {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    border-radius: 50%;
    color: #6b7280;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-contact:hover {
    background: #e5e7eb;
    color: #374151;
}

/* ===========================
   Quick Feedback Buttons (Panel Header)
   =========================== */

.quick-feedback {
    display: flex;
    gap: 8px;
}

.quick-feedback.hidden {
    display: none;
}

.btn-feedback {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid;
}

.btn-helpful {
    background: #f0fdf4;
    color: #15803d;
    border-color: #86efac;
}

.btn-helpful:hover {
    background: #dcfce7;
    border-color: #4ade80;
}

.btn-helpful.selected {
    background: #15803d;
    color: white;
    border-color: #15803d;
}

.btn-improve {
    background: #fef2f2;
    color: #b91c1c;
    border-color: #fecaca;
}

.btn-improve:hover {
    background: #fee2e2;
    border-color: #f87171;
}

.btn-improve.selected {
    background: #b91c1c;
    color: white;
    border-color: #b91c1c;
}

.btn-feedback:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-feedback svg {
    flex-shrink: 0;
}

/* ===========================
   Modal
   =========================== */

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: white;
    border-radius: 12px;
    width: 90%;
    max-width: 450px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid #e5e7eb;
}

.modal-header h2 {
    font-size: 20px;
    font-weight: 600;
    color: #1a1a2e;
}

.modal-close {
    background: none;
    border: none;
    font-size: 28px;
    color: #6b7280;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: all 0.2s;
}

.modal-close:hover {
    color: #1a1a2e;
    background: #f3f4f6;
}

.modal-body {
    padding: 24px;
}

.auth-step {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.auth-step.hidden {
    display: none;
}

.auth-step p {
    color: #6b7280;
    font-size: 14px;
}

.input-field {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    font-size: 16px;
    font-family: inherit;
    transition: border-color 0.2s;
}

.input-field:focus {
    outline: none;
    border-color: #2563eb;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: #6b7280;
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.btn-primary {
    background: #2563eb;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
    width: 100%;
}

.btn-primary:hover {
    background: #1d4ed8;
}

.btn-link {
    background: none;
    border: none;
    color: #2563eb;
    text-decoration: underline;
    cursor: pointer;
    padding: 8px;
    font-size: 14px;
}

.btn-link:hover {
    color: #1d4ed8;
}

/* ===========================
   Toast Notifications
   =========================== */

.toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1001;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    min-width: 300px;
    padding: 16px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    justify-content: space-between;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.toast.success {
    background: #10b981;
    color: white;
}

.toast.error {
    background: #ef4444;
    color: white;
}

.toast.warning {
    background: #f59e0b;
    color: white;
}

.toast.info {
    background: #3b82f6;
    color: white;
}

.toast-message {
    flex: 1;
    font-size: 14px;
}

.toast-close {
    background: none;
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    padding: 0 0 0 10px;
}

/* ===========================
   Utility Classes
   =========================== */

.hidden {
    display: none !important;
}

/* ===========================
   Responsive Design
   =========================== */

@media (max-width: 900px) {
    .editor-container {
        grid-template-columns: 1fr;
        min-height: auto;
    }

    .editor-panel {
        min-height: 350px;
        height: auto;
    }
}

@media (max-width: 768px) {
    .app-header {
        flex-direction: column;
        gap: 16px;
        padding: 16px 20px;
        text-align: center;
    }

    .header-brand {
        align-items: center;
    }

    .header-actions {
        width: 100%;
        justify-content: center;
    }

    .main-content {
        padding: 20px;
    }

    .tone-tabs {
        justify-content: center;
        flex-wrap: wrap;
    }

    .tone-tab {
        padding: 10px 16px;
        font-size: 14px;
    }

    .output-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .btn-copy,
    .btn-export {
        justify-content: center;
    }

    .btn-rephrase {
        padding: 14px 32px;
        font-size: 15px;
    }

    .toast {
        min-width: 250px;
    }

    .modal-content {
        width: 95%;
    }
}

@media (max-width: 480px) {
    .app-header h1 {
        font-size: 22px;
    }

    .header-actions {
        flex-direction: column;
        gap: 8px;
    }

    .quota-badge {
        width: 100%;
        text-align: center;
    }

    .btn-login {
        width: 100%;
    }

    .tone-tab {
        padding: 8px 12px;
        font-size: 13px;
    }

    .panel-header {
        padding: 12px 16px;
    }

    .editor-textarea,
    .editor-output {
        padding: 16px;
        font-size: 15px;
    }

    .panel-footer {
        padding: 10px 16px;
        flex-wrap: wrap;
        gap: 8px;
    }

    .toast-container {
        bottom: 10px;
        right: 10px;
        left: 10px;
    }

    .toast {
        min-width: auto;
    }
}

/* ===========================
   Feedback Modal
   =========================== */

.feedback-modal-content {
    max-width: 500px;
}

.feedback-intro {
    color: #6b7280;
    font-size: 14px;
    margin-bottom: 20px;
    line-height: 1.5;
}

.feedback-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    font-size: 14px;
    font-weight: 500;
    color: #374151;
}

.form-group .optional {
    color: #9ca3af;
    font-weight: 400;
}

.form-group .required {
    color: #ef4444;
}

.feedback-textarea {
    min-height: 120px;
    resize: vertical;
}

.textarea-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 4px;
}

.field-error {
    color: #ef4444;
    font-size: 12px;
}

.field-error.hidden {
    display: none;
}

/* Honeypot field - hidden from users */
.honeypot {
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
    opacity: 0;
}

.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 8px;
}

.btn-secondary {
    background: white;
    color: #374151;
    border: 1px solid #e5e7eb;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    flex: 1;
}

.btn-secondary:hover {
    background: #f9fafb;
    border-color: #d1d5db;
}

.form-actions .btn-primary {
    flex: 1;
}

.btn-primary:disabled {
    background: #93c5fd;
    cursor: not-allowed;
}

/* Feedback Success State */
.feedback-success {
    text-align: center;
    padding: 20px 0;
}

.feedback-success.hidden {
    display: none;
}

.feedback-success .success-icon {
    width: 60px;
    height: 60px;
    background: #d1fae5;
    color: #10b981;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    margin: 0 auto 20px;
}

.feedback-success h3 {
    color: #1a1a2e;
    font-size: 20px;
    margin-bottom: 12px;
}

.feedback-success p {
    color: #6b7280;
    font-size: 14px;
    line-height: 1.6;
    margin-bottom: 24px;
}

.feedback-success .btn-primary {
    width: auto;
    padding: 12px 32px;
}

/* Select dropdown styling */
select.input-field {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b7280' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
    cursor: pointer;
}

/* Feedback link in footer */
#feedback-link {
    cursor: pointer;
}

/* Responsive feedback modal */
@media (max-width: 480px) {
    .feedback-modal-content {
        max-height: 90vh;
        overflow-y: auto;
    }

    .form-actions {
        flex-direction: column;
    }

    .btn-secondary,
    .form-actions .btn-primary {
        width: 100%;
    }
}
