/* ============================================
   TaxBE Design System
   Aesthetic: Elegant Authority — Premium Fintech
   ============================================ */

/* ---- Typography ---- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&display=swap');

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

/* Tight tracking for large display headings */
.heading-display {
    letter-spacing: -0.035em;
    line-height: 1.05;
}

/* ---- Refined Shadow System ---- */
.shadow-premium {
    box-shadow:
        0 1px 2px 0 rgba(0, 0, 0, 0.03),
        0 4px 16px 0 rgba(0, 0, 0, 0.06);
}

.shadow-premium-lg {
    box-shadow:
        0 2px 8px 0 rgba(0, 0, 0, 0.04),
        0 12px 40px 0 rgba(0, 0, 0, 0.1);
}

/* ---- Hero ---- */
.hero-gradient {
    background:
        radial-gradient(ellipse 80% 60% at 50% 0%, rgba(59, 130, 246, 0.08) 0%, transparent 70%),
        radial-gradient(ellipse 60% 50% at 80% 100%, rgba(16, 185, 129, 0.05) 0%, transparent 70%),
        linear-gradient(180deg, #f8fafc 0%, #ffffff 100%);
}

/* ---- CTA Button ---- */
.btn-primary {
    background: #2563eb;
    transition: background 0.15s ease;
}

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

.btn-primary:active {
    background: #1e40af;
}

/* ---- Card Hover ---- */
.card-hover {
    transition: transform 0.25s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.25s cubic-bezier(0.22, 1, 0.36, 1);
}

.card-hover:hover {
    transform: translateY(-4px);
    box-shadow:
        0 4px 12px 0 rgba(0, 0, 0, 0.04),
        0 16px 48px 0 rgba(0, 0, 0, 0.1);
}

/* ---- Section Title Overlines ---- */
.section-overline {
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: #3b82f6;
}

/* ---- Results Header ---- */
.results-gradient {
    background: linear-gradient(135deg, #1e40af 0%, #2563eb 50%, #3b82f6 100%);
}

/* ---- Savings Card Accent ---- */
.savings-card {
    background: linear-gradient(135deg, #ecfdf5 0%, #d1fae5 100%);
    border-color: #6ee7b7;
    position: relative;
}

.savings-card::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    padding: 1px;
    background: linear-gradient(135deg, #34d399, #10b981);
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    pointer-events: none;
}

/* ---- Section Backgrounds ---- */
.section-alt {
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
}

/* ---- Premium Input Focus ---- */
input:focus,
textarea:focus {
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

/* ---- FAQ ---- */
.faq-toggle[aria-expanded="true"] .faq-chevron {
    transform: rotate(180deg);
}

/* ---- Scroll Offset ---- */
[id] {
    scroll-margin-top: 5rem;
}

/* ---- Scroll Reveal Animations ---- */
.reveal {
    opacity: 0;
    transform: translateY(24px);
    transition: opacity 0.7s cubic-bezier(0.22, 1, 0.36, 1), transform 0.7s cubic-bezier(0.22, 1, 0.36, 1);
}

.reveal.visible {
    opacity: 1;
    transform: translateY(0);
}

/* Staggered children */
.reveal-stagger > .reveal-child {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.5s cubic-bezier(0.22, 1, 0.36, 1), transform 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}

.reveal-stagger.visible > .reveal-child {
    opacity: 1;
    transform: translateY(0);
}

.reveal-stagger.visible > .reveal-child:nth-child(1) { transition-delay: 0ms; }
.reveal-stagger.visible > .reveal-child:nth-child(2) { transition-delay: 80ms; }
.reveal-stagger.visible > .reveal-child:nth-child(3) { transition-delay: 160ms; }
.reveal-stagger.visible > .reveal-child:nth-child(4) { transition-delay: 240ms; }
.reveal-stagger.visible > .reveal-child:nth-child(5) { transition-delay: 320ms; }
.reveal-stagger.visible > .reveal-child:nth-child(6) { transition-delay: 400ms; }

/* ---- Chat Animations & Bubbles ---- */
.chat-message-enter {
    animation: messageSlideIn 0.25s ease-out;
}

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

.chat-bubble {
    border-radius: 1.25rem;
    padding: 0.875rem 1.125rem;
    max-width: 85%;
    line-height: 1.5;
    word-wrap: break-word;
    overflow-wrap: break-word;
    display: inline-block;
    font-size: 0.9375rem;
    font-weight: 400;
    letter-spacing: -0.01em;
}

.chat-bubble-user {
    margin-left: auto;
    color: #fff;
    background: linear-gradient(135deg, #3525cd 0%, #4f46e5 100%);
    box-shadow:
        0 2px 4px rgba(53, 37, 205, 0.12),
        0 8px 20px rgba(53, 37, 205, 0.16);
    border-radius: 1.25rem 0.375rem 1.25rem 1.25rem;
    font-weight: 500;
}

.chat-bubble-system {
    color: #191c1d;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.98) 0%, rgba(248, 250, 252, 0.95) 100%);
    border: 1px solid rgba(110, 96, 168, 0.08);
    box-shadow: 0 2px 8px rgba(25, 28, 29, 0.04);
    border-radius: 0.375rem 1.25rem 1.25rem 1.25rem;
}

#chat-messages {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

#legal-chat-messages {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.quick-reply-chip {
    border-radius: 0.75rem;
    border: 1px solid rgba(110, 96, 168, 0.2);
    background: rgba(255, 255, 255, 0.7);
    color: #64748b;
    transition: all 0.2s ease;
}

.quick-reply-chip:hover {
    border-color: rgba(53, 37, 205, 0.4);
    background: rgba(237, 235, 255, 0.9);
    color: #3525cd;
}

/* ---- Optimization Cards ---- */
.optimization-card {
    border: 1px solid rgba(110, 96, 168, 0.12);
    border-radius: 1.25rem;
    overflow: hidden;
    background: linear-gradient(180deg, rgba(248, 250, 252, 0.95), rgba(245, 243, 251, 0.98));
    box-shadow: 0 8px 24px rgba(25, 28, 29, 0.04);
    transition: all 0.3s ease;
}

.optimization-card:hover {
    border-color: rgba(53, 37, 205, 0.2);
    box-shadow: 0 12px 32px rgba(53, 37, 205, 0.1);
}

.optimization-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    background: linear-gradient(90deg, rgba(245, 243, 251, 0.8), rgba(248, 250, 252, 0.95));
    border-bottom: 1px solid rgba(110, 96, 168, 0.08);
}

.optimization-card-body {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.optimization-instruction {
    border-radius: 1rem;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.05), rgba(139, 92, 246, 0.05));
    border: 1px solid rgba(139, 92, 246, 0.15);
    padding: 1rem;
}

/* ---- Upload Area ---- */
.upload-area {
    border: 2px dashed #cbd5e1;
    background:
        radial-gradient(ellipse at center, rgba(59, 130, 246, 0.03) 0%, transparent 70%),
        #f8fafc;
    transition: all 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}

.upload-area:hover {
    border-color: #93c5fd;
    background:
        radial-gradient(ellipse at center, rgba(59, 130, 246, 0.06) 0%, transparent 70%),
        #eff6ff;
    transform: scale(1.01);
}

/* ---- Upload Status Animation ---- */
#upload-status {
    animation: statusSlideIn 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes statusSlideIn {
    from {
        opacity: 0;
        transform: translateY(-12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Animated progress bar */
.upload-progress-bar {
    animation: progressPulse 2s ease-in-out infinite;
}

@keyframes progressPulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
}

/* Loading spinner for "thinking" state */
.ai-thinking {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.ai-thinking-dots {
    display: inline-flex;
    gap: 0.25rem;
}

.ai-thinking-dot {
    width: 0.375rem;
    height: 0.375rem;
    border-radius: 50%;
    background-color: currentColor;
    animation: thinkingBounce 1.4s infinite;
}

.ai-thinking-dot:nth-child(1) {
    animation-delay: 0s;
}

.ai-thinking-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.ai-thinking-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes thinkingBounce {
    0%, 60%, 100% {
        opacity: 0.3;
        transform: translateY(0);
    }
    30% {
        opacity: 1;
        transform: translateY(-6px);
    }
}

/* ---- Timeline ---- */
.timeline-line {
    background: linear-gradient(180deg, #3b82f6 0%, #93c5fd 50%, #3b82f6 100%);
}

.timeline-dot {
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.15);
    transition: box-shadow 0.3s ease;
}

/* ---- Nav Scroll State ---- */
.nav-scrolled {
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

/* ---- Mobile Responsive Styles ---- */
@media (max-width: 768px) {
    /* Chat bubbles on mobile */
    .chat-bubble {
        max-width: 90%;
        padding: 0.75rem 1rem;
        font-size: 0.875rem;
    }

    /* Results grid on mobile */
    #result-screen .grid {
        grid-template-columns: 1fr;
    }

    /* Header responsive */
    header {
        padding: 1rem 0.5rem;
    }

    /* Main content padding */
    main {
        padding: 0.5rem;
    }

    /* Results savings card */
    .savings-card {
        min-width: auto;
        margin-top: 1.5rem;
        width: 100%;
        text-align: center;
    }

    .savings-card p {
        text-align: center;
    }

    /* Optimization cards stack properly */
    .optimization-card {
        border-radius: 1rem;
    }

    .optimization-card-header {
        padding: 1rem;
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .optimization-card-body {
        padding: 1rem;
    }

    /* Chat input on mobile */
    #chat-form {
        flex-wrap: wrap;
    }

    #chat-input {
        font-size: 16px; /* Prevents zoom on iOS */
    }

    /* Upload panel responsive */
    #upload-panel {
        padding: 1.5rem;
    }

    /* Results comparison grid */
    .grid.grid-cols-3 {
        grid-template-columns: 1fr;
    }

    .text-right,
    .text-center {
        text-align: left;
    }

    /* Heading sizes on mobile */
    .heading-display {
        font-size: 1.875rem;
        line-height: 1.2;
    }

    h1 {
        font-size: 1.75rem;
    }

    h2 {
        font-size: 1.5rem;
    }

    h3 {
        font-size: 1.25rem;
    }

    /* Payment overlay responsive */
    #payment-overlay {
        padding: 1.5rem;
    }

    /* Chat screen responsive */
    #chat-screen {
        height: auto;
        min-height: 60vh;
    }

    #legal-chat-screen {
        height: auto;
        min-height: 60vh;
    }

    /* Buttons responsive */
    .btn-primary,
    .btn-secondary {
        width: 100%;
        padding: 1rem;
    }

    /* Table cells responsive */
    .optimization-card {
        margin-bottom: 1rem;
    }
}

@media (max-width: 640px) {
    .chat-bubble {
        max-width: 95%;
    }

    /* Extra small heading adjustments */
    .heading-display {
        font-size: 1.5rem;
    }

    h1 {
        font-size: 1.5rem;
    }

    /* Remove min-width constraints */
    .savings-card {
        min-width: unset;
    }

    /* Full width on small screens */
    [class*="max-w-"] {
        max-width: 100%;
    }

    /* Reduce padding on small screens */
    section,
    .optimization-card,
    .editorial-panel {
        padding: 1rem;
        border-radius: 1rem;
    }

    /* Adjust grid layouts */
    .grid {
        gap: 1rem;
    }

    /* Mobile-friendly spacing */
    main {
        padding: 0.25rem;
    }

    /* Chat messages better spacing on small */
    #chat-messages,
    #legal-chat-messages {
        gap: 1rem;
        padding: 1rem 0.5rem;
    }
}

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
    .reveal,
    .reveal-stagger > .reveal-child {
        opacity: 1;
        transform: none;
        transition: none;
    }
    .card-hover:hover {
        transform: none;
    }
    .btn-primary:hover {
        transform: none;
    }
    .upload-area:hover {
        transform: none;
    }
}
