/* AI Email Composer - Styles */

:root {
    --email-primary: #2563eb;
    --email-secondary: #0ea5e9;
    --email-gradient: linear-gradient(135deg, #2563eb 0%, #0ea5e9 100%);
    --card-bg: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --radius: 12px;
}

@media (prefers-color-scheme: dark) {
    :root {
        --card-bg: #1e2433;
        --text-primary: #e2e8f0;
        --text-secondary: #94a3b8;
        --border-color: #2d3748;
    }
}

/* ── Hero ── */
.email-hero {
    background: linear-gradient(135deg, #1e3a5f 0%, #2563eb 55%, #0ea5e9 100%);
    background-size: 200% 200%;
    animation: heroShift 10s ease infinite;
    position: relative;
    overflow: hidden;
    padding: 4rem 2rem;
    text-align: center;
    color: white;
}

.email-hero::before {
    content: '';
    position: absolute;
    top: -60%;
    right: -20%;
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, rgba(255,255,255,0.08) 0%, transparent 70%);
    animation: float 12s ease-in-out infinite;
}

.email-hero::after {
    content: '';
    position: absolute;
    bottom: -40%;
    left: -10%;
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(14,165,233,0.15) 0%, transparent 70%);
    animation: float 15s ease-in-out infinite reverse;
}

@keyframes heroShift {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

@keyframes float {
    0%, 100% { transform: translateY(0) scale(1); }
    50% { transform: translateY(-20px) scale(1.05); }
}

.email-hero h1 {
    font-size: clamp(1.8rem, 4vw, 2.8rem);
    font-weight: 800;
    margin-bottom: 1rem;
    position: relative;
    z-index: 1;
}

.email-hero p {
    font-size: clamp(1rem, 2vw, 1.2rem);
    opacity: 0.9;
    max-width: 600px;
    margin: 0 auto;
    position: relative;
    z-index: 1;
}

/* ── Main Layout ── */
.composer-container {
    max-width: 1300px;
    margin: 0 auto;
    padding: 2rem;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    align-items: start;
    animation: fadeInUp 0.5s ease;
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(16px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ── Panels ── */
.form-panel,
.output-panel {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    padding: 1.75rem;
    border: 1px solid var(--border-color);
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--border-color);
}

.panel-header h2 {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

/* ── Form Fields ── */
.field-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.field-group {
    margin-bottom: 1.25rem;
}

.field-group label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.optional {
    font-weight: 400;
    color: var(--text-secondary);
    font-size: 0.78rem;
}

.char-count {
    font-weight: 400;
    color: var(--text-secondary);
    font-size: 0.78rem;
}

.field-group input[type="text"],
.field-group select,
.field-group textarea {
    width: 100%;
    padding: 0.65rem 0.9rem;
    border: 1.5px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.9rem;
    font-family: inherit;
    color: var(--text-primary);
    background: var(--card-bg);
    transition: var(--transition);
    box-sizing: border-box;
}

.field-group input[type="text"]:focus,
.field-group select:focus,
.field-group textarea:focus {
    outline: none;
    border-color: var(--email-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.field-group textarea {
    resize: vertical;
    min-height: 130px;
    line-height: 1.6;
}

/* ── Tone Buttons ── */
.tone-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.6rem;
}

.tone-btn {
    padding: 0.55rem 0.5rem;
    border: 1.5px solid var(--border-color);
    border-radius: 8px;
    background: var(--card-bg);
    color: var(--text-primary);
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    text-align: center;
    font-family: inherit;
}

.tone-btn:hover {
    border-color: var(--email-primary);
    color: var(--email-primary);
    background: rgba(37, 99, 235, 0.05);
}

.tone-btn.active {
    background: var(--email-gradient);
    border-color: var(--email-primary);
    color: white;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.35);
}

/* ── Action Buttons ── */
.action-buttons {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0.75rem;
    margin-top: 0.5rem;
}

.compose-btn {
    padding: 0.8rem 1.5rem;
    background: var(--email-gradient);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
    letter-spacing: 0.01em;
}

.compose-btn:hover:not(:disabled) {
    box-shadow: 0 4px 16px rgba(37, 99, 235, 0.4);
    transform: translateY(-1px);
}

.compose-btn:disabled {
    opacity: 0.65;
    cursor: not-allowed;
    transform: none;
}

.sample-btn {
    padding: 0.8rem 1rem;
    background: transparent;
    color: var(--email-primary);
    border: 1.5px solid var(--email-primary);
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
    white-space: nowrap;
}

.sample-btn:hover {
    background: rgba(37, 99, 235, 0.06);
}

.clear-btn {
    padding: 0.35rem 0.75rem;
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
}

.clear-btn:hover {
    border-color: #ef4444;
    color: #ef4444;
    background: rgba(239, 68, 68, 0.05);
}

.regenerate-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.85rem;
    background: transparent;
    color: var(--email-primary);
    border: 1.5px solid var(--email-primary);
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
}

.regenerate-btn:hover {
    background: rgba(37, 99, 235, 0.06);
}

/* ── Output States ── */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3.5rem 1.5rem;
    text-align: center;
    color: var(--text-secondary);
    min-height: 300px;
}

.empty-icon {
    font-size: 3.5rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-state p {
    margin: 0.25rem 0;
    font-size: 0.95rem;
}

.empty-hint {
    font-size: 0.82rem !important;
    opacity: 0.7;
}

.loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3.5rem 1.5rem;
    gap: 1rem;
    color: var(--text-secondary);
    min-height: 300px;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-color);
    border-top-color: var(--email-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* ── Email Output ── */
.email-output {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.email-output.slide-in {
    animation: slideIn 0.4s ease;
}

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

.output-block {
    border: 1.5px solid var(--border-color);
    border-radius: 10px;
    overflow: hidden;
}

.output-block-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.6rem 1rem;
    background: linear-gradient(to right, rgba(37,99,235,0.06), rgba(14,165,233,0.04));
    border-bottom: 1px solid var(--border-color);
}

.output-label {
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--email-primary);
}

.copy-btn {
    padding: 0.25rem 0.65rem;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 5px;
    font-size: 0.75rem;
    cursor: pointer;
    color: var(--text-secondary);
    transition: var(--transition);
    font-family: inherit;
}

.copy-btn:hover {
    border-color: var(--email-primary);
    color: var(--email-primary);
}

.subject-output {
    padding: 0.85rem 1rem;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.5;
}

.body-output {
    padding: 1rem;
    font-size: 0.9rem;
    color: var(--text-primary);
    line-height: 1.75;
    white-space: pre-wrap;
    min-height: 180px;
}

.copy-all-btn {
    width: 100%;
    padding: 0.8rem;
    background: transparent;
    border: 2px dashed var(--border-color);
    border-radius: 8px;
    color: var(--text-secondary);
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
}

.copy-all-btn:hover {
    border-color: var(--email-primary);
    color: var(--email-primary);
    background: rgba(37, 99, 235, 0.04);
    border-style: solid;
}

/* ── Toast Feedback ── */
.feedback-toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: #1e293b;
    color: white;
    padding: 0.7rem 1.5rem;
    border-radius: 50px;
    font-size: 0.88rem;
    font-weight: 500;
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s ease;
    z-index: 1000;
    white-space: nowrap;
}

.feedback-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.feedback-toast.error {
    background: #dc2626;
}

/* ── Mobile ── */
@media (max-width: 900px) {
    .composer-container {
        grid-template-columns: 1fr;
        padding: 1.25rem;
        gap: 1.25rem;
    }

    .field-row {
        grid-template-columns: 1fr;
    }

    .tone-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .action-buttons {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .email-hero {
        padding: 2.5rem 1rem;
    }

    .form-panel,
    .output-panel {
        padding: 1.25rem;
    }

    .tone-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}
