/* ============================================================
   APPEALARMOR UNIFIED DESIGN SYSTEM v2.0
   Created: 2025-12-10

   PURPOSE: Single source of truth for all visual styling
   This file MUST load LAST to override all other CSS

   DESIGN PHILOSOPHY:
   - Professional medical advocacy aesthetic
   - Maximum readability and accessibility
   - Clear visual hierarchy guiding users to action
   - Consistent spacing and typography rhythm
   - Buttons that are UNMISTAKABLY clickable
   ============================================================ */

/* ============================================================
   1. DESIGN TOKENS - Single source of truth for all values
   ============================================================ */

:root {
    /* === COLOR PALETTE === */
    /* Primary - Trust & Success */
    --aa-green-900: #14532d;
    --aa-green-800: #166534;
    --aa-green-700: #15803d;
    --aa-green-600: #16a34a;
    --aa-green-500: #22c55e;
    --aa-green-400: #4ade80;
    --aa-green-100: #dcfce7;
    --aa-green-50: #f0fdf4;

    /* Secondary - Authority & Expertise */
    --aa-navy-900: #0f172a;
    --aa-navy-800: #1e3a5f;
    --aa-navy-700: #1e40af;
    --aa-navy-600: #2563eb;
    --aa-navy-100: #dbeafe;
    --aa-navy-50: #eff6ff;

    /* Neutral - Text & Backgrounds */
    --aa-gray-900: #18181b;
    --aa-gray-800: #27272a;
    --aa-gray-700: #3f3f46;
    --aa-gray-600: #52525b;
    --aa-gray-500: #71717a;
    --aa-gray-400: #a1a1aa;
    --aa-gray-300: #d4d4d8;
    --aa-gray-200: #e4e4e7;
    --aa-gray-100: #f4f4f5;
    --aa-gray-50: #fafafa;

    /* Accent - Attention & Warning */
    --aa-amber-500: #f59e0b;
    --aa-amber-100: #fef3c7;
    --aa-amber-50: #fffbeb;
    --aa-red-500: #ef4444;
    --aa-red-100: #fee2e2;

    /* Backgrounds */
    --aa-bg-page: #fefdfb;  /* Warm off-white, not clinical */
    --aa-bg-section: #f8fafc;
    --aa-bg-card: #ffffff;

    /* === TYPOGRAPHY === */
    --aa-font-display: 'Poppins', -apple-system, BlinkMacSystemFont, sans-serif;
    --aa-font-body: 'Poppins', -apple-system, BlinkMacSystemFont, sans-serif;
    --aa-font-mono: 'Fira Code', 'Courier New', monospace;

    /* Font Sizes - Fluid Typography */
    --aa-text-xs: 0.75rem;    /* 12px */
    --aa-text-sm: 0.875rem;   /* 14px */
    --aa-text-base: 1rem;     /* 16px */
    --aa-text-lg: 1.125rem;   /* 18px */
    --aa-text-xl: 1.25rem;    /* 20px */
    --aa-text-2xl: 1.5rem;    /* 24px */
    --aa-text-3xl: 1.875rem;  /* 30px */
    --aa-text-4xl: 2.25rem;   /* 36px */

    /* Line Heights */
    --aa-leading-tight: 1.2;
    --aa-leading-normal: 1.5;
    --aa-leading-relaxed: 1.65;

    /* === SPACING === */
    --aa-space-1: 0.25rem;   /* 4px */
    --aa-space-2: 0.5rem;    /* 8px */
    --aa-space-3: 0.75rem;   /* 12px */
    --aa-space-4: 1rem;      /* 16px */
    --aa-space-5: 1.25rem;   /* 20px */
    --aa-space-6: 1.5rem;    /* 24px */
    --aa-space-8: 2rem;      /* 32px */
    --aa-space-10: 2.5rem;   /* 40px */
    --aa-space-12: 3rem;     /* 48px */
    --aa-space-16: 4rem;     /* 64px */

    /* === BORDERS & SHADOWS === */
    --aa-radius-sm: 0.375rem;  /* 6px */
    --aa-radius-md: 0.5rem;    /* 8px */
    --aa-radius-lg: 0.75rem;   /* 12px */
    --aa-radius-xl: 1rem;      /* 16px */
    --aa-radius-2xl: 1.5rem;   /* 24px */
    --aa-radius-full: 9999px;

    --aa-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --aa-shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
    --aa-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
    --aa-shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);

    /* === TRANSITIONS === */
    --aa-transition-fast: 150ms ease;
    --aa-transition-normal: 250ms ease;
    --aa-transition-slow: 400ms ease;
}

/* ============================================================
   2. BASE STYLES - Foundation for everything
   ============================================================ */

body {
    font-family: var(--aa-font-body) !important;
    font-size: var(--aa-text-base) !important;
    line-height: var(--aa-leading-relaxed) !important;
    color: var(--aa-gray-900) !important;
    background: linear-gradient(180deg, var(--aa-bg-page) 0%, #f8f7f4 100%) !important;
    -webkit-font-smoothing: antialiased !important;
    -moz-osx-font-smoothing: grayscale !important;
}

/* Headings - Clear hierarchy */
h1, h2, h3, h4, h5, h6 {
    font-family: var(--aa-font-display) !important;
    font-weight: 700 !important;
    line-height: var(--aa-leading-tight) !important;
    color: var(--aa-gray-900) !important;
    letter-spacing: -0.02em !important;
}

h1 { font-size: var(--aa-text-4xl) !important; }
h2 { font-size: var(--aa-text-3xl) !important; }
h3 { font-size: var(--aa-text-2xl) !important; }
h4 { font-size: var(--aa-text-xl) !important; }

/* Paragraph text - Maximum readability */
p {
    color: var(--aa-gray-700) !important;
    line-height: var(--aa-leading-relaxed) !important;
}

/* ============================================================
   3. PRIMARY CTA BUTTONS - UNMISTAKABLY CLICKABLE
   3D effect with depth, hover lift, press feedback
   ============================================================ */

/* The main "Start Appeal" button and all green action buttons */
#startAppealBtn,
button.bg-green-600,
button.bg-green-700,
.bg-green-600[onclick],
.bg-green-700[onclick],
.hero-cta-button {
    /* Multi-layer gradient for depth */
    background: linear-gradient(180deg,
        var(--aa-green-400) 0%,
        var(--aa-green-500) 15%,
        var(--aa-green-600) 85%,
        var(--aa-green-700) 100%) !important;

    /* No border - shadow creates the 3D effect */
    border: none !important;
    border-radius: var(--aa-radius-xl) !important;

    /* THE 3D SHADOW - This is what makes it look like a button */
    box-shadow:
        0 6px 0 var(--aa-green-900),
        0 8px 12px rgba(20, 83, 45, 0.35),
        inset 0 1px 0 rgba(255, 255, 255, 0.25),
        inset 0 -2px 0 rgba(0, 0, 0, 0.1) !important;

    /* Text styling - bold, white, readable */
    color: #ffffff !important;
    font-family: var(--aa-font-display) !important;
    font-weight: 800 !important;
    font-size: var(--aa-text-xl) !important;
    letter-spacing: 0.01em !important;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2) !important;
    text-transform: none !important;

    /* Sizing */
    padding: 1.25rem 2.5rem !important;
    min-height: 60px !important;

    /* Interaction setup */
    cursor: pointer !important;
    position: relative !important;
    transform: translateY(0) !important;
    transition:
        transform 0.12s cubic-bezier(0.34, 1.56, 0.64, 1),
        box-shadow 0.12s ease !important;

    /* Ensure clickable */
    z-index: 10 !important;
    overflow: visible !important;
}

/* HOVER STATE - Button lifts up, shadow extends */
#startAppealBtn:hover,
button.bg-green-600:hover,
button.bg-green-700:hover,
.bg-green-600[onclick]:hover,
.bg-green-700[onclick]:hover,
.hero-cta-button:hover {
    background: linear-gradient(180deg,
        #6ee7b7 0%,
        var(--aa-green-400) 15%,
        var(--aa-green-500) 85%,
        var(--aa-green-600) 100%) !important;

    transform: translateY(-4px) !important;

    box-shadow:
        0 10px 0 var(--aa-green-900),
        0 14px 20px rgba(20, 83, 45, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.3),
        inset 0 -2px 0 rgba(0, 0, 0, 0.1) !important;
}

/* ACTIVE/PRESSED STATE - Button pushes down */
#startAppealBtn:active,
button.bg-green-600:active,
button.bg-green-700:active,
.bg-green-600[onclick]:active,
.bg-green-700[onclick]:active,
.hero-cta-button:active {
    transform: translateY(4px) !important;

    box-shadow:
        0 2px 0 var(--aa-green-900),
        0 4px 8px rgba(20, 83, 45, 0.25),
        inset 0 2px 4px rgba(0, 0, 0, 0.15) !important;

    transition:
        transform 0.06s ease,
        box-shadow 0.06s ease !important;
}

/* FOCUS STATE - Accessibility */
#startAppealBtn:focus-visible,
button.bg-green-600:focus-visible,
button.bg-green-700:focus-visible {
    outline: 3px solid rgba(74, 222, 128, 0.6) !important;
    outline-offset: 4px !important;
}

/* Arrow icon animation on hover */
#startAppealBtn i.fa-arrow-right,
button.bg-green-600 i.fa-arrow-right,
button.bg-green-700 i.fa-arrow-right {
    transition: transform var(--aa-transition-fast) !important;
    display: inline-block !important;
}

#startAppealBtn:hover i.fa-arrow-right,
button.bg-green-600:hover i.fa-arrow-right,
button.bg-green-700:hover i.fa-arrow-right {
    transform: translateX(6px) !important;
}

/* Gentle attention pulse (doesn't interfere with interaction) */
@keyframes gentle-pulse {
    0%, 100% {
        box-shadow:
            0 6px 0 var(--aa-green-900),
            0 8px 12px rgba(20, 83, 45, 0.35),
            inset 0 1px 0 rgba(255, 255, 255, 0.25),
            0 0 0 0 rgba(74, 222, 128, 0.4);
    }
    50% {
        box-shadow:
            0 6px 0 var(--aa-green-900),
            0 8px 12px rgba(20, 83, 45, 0.35),
            inset 0 1px 0 rgba(255, 255, 255, 0.25),
            0 0 0 15px rgba(74, 222, 128, 0);
    }
}

#startAppealBtn.pulse-animation {
    animation: gentle-pulse 2.5s ease-in-out infinite !important;
}

#startAppealBtn.pulse-animation:hover,
#startAppealBtn.pulse-animation:active {
    animation: none !important;
}

/* ============================================================
   4. SECONDARY BUTTONS - Supporting actions
   ============================================================ */

/* Blue buttons (upload, submit) */
.bg-blue-600,
button.bg-blue-600,
.pat-upload-button {
    background: linear-gradient(180deg,
        var(--aa-navy-600) 0%,
        var(--aa-navy-700) 100%) !important;
    border: none !important;
    border-radius: var(--aa-radius-lg) !important;
    box-shadow:
        0 4px 0 #1e3a8a,
        0 6px 10px rgba(30, 64, 175, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.2) !important;
    color: #ffffff !important;
    font-weight: 700 !important;
    cursor: pointer !important;
    transform: translateY(0) !important;
    transition: transform 0.12s ease, box-shadow 0.12s ease !important;
}

.bg-blue-600:hover,
button.bg-blue-600:hover,
.pat-upload-button:hover {
    transform: translateY(-2px) !important;
    box-shadow:
        0 6px 0 #1e3a8a,
        0 8px 15px rgba(30, 64, 175, 0.35),
        inset 0 1px 0 rgba(255, 255, 255, 0.25) !important;
}

.bg-blue-600:active,
button.bg-blue-600:active,
.pat-upload-button:active {
    transform: translateY(2px) !important;
    box-shadow:
        0 2px 0 #1e3a8a,
        0 3px 6px rgba(30, 64, 175, 0.2) !important;
}

/* ============================================================
   5. FOUNDER BOX - Navy gradient with WHITE text
   ============================================================ */

.founder-box,
#heroSection .bg-blue-50.rounded-2xl,
.bg-blue-50.rounded-2xl.p-6,
.bg-blue-50.rounded-2xl.p-8 {
    background: linear-gradient(135deg,
        var(--aa-navy-800) 0%,
        #2a5a8f 50%,
        var(--aa-navy-700) 100%) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    box-shadow: var(--aa-shadow-lg) !important;
}

/* ALL text in founder box must be white */
.founder-box h1,
.founder-box h2,
.founder-box h3,
.founder-box h4,
.founder-box p,
.founder-box span,
.founder-box .text-gray-600,
.founder-box .text-gray-700,
.founder-box .text-gray-800,
.founder-box .text-gray-900,
.founder-box .text-xl,
.founder-box .text-xs,
#heroSection .bg-blue-50.rounded-2xl h3,
#heroSection .bg-blue-50.rounded-2xl p,
#heroSection .bg-blue-50.rounded-2xl span,
#heroSection .bg-blue-50.rounded-2xl .text-gray-600,
#heroSection .bg-blue-50.rounded-2xl .text-gray-700,
#heroSection .bg-blue-50.rounded-2xl .text-gray-900,
#heroSection .bg-blue-50.rounded-2xl .text-xs {
    color: #ffffff !important;
}

/* Icon container in founder box */
.founder-box .bg-gray-200,
#heroSection .bg-blue-50.rounded-2xl .bg-gray-200 {
    background: rgba(255, 255, 255, 0.15) !important;
}

/* Icons in founder box */
.founder-box i.fas,
.founder-box i.far,
#heroSection .bg-blue-50.rounded-2xl i.fas {
    color: rgba(255, 255, 255, 0.9) !important;
}

/* Green checkmarks stay visible green */
.founder-box .text-green-600,
#heroSection .bg-blue-50.rounded-2xl .text-green-600 {
    color: var(--aa-green-400) !important;
}

/* ============================================================
   6. SECTION BACKGROUNDS - Visual Rhythm
   ============================================================ */

/* Hero section - subtle gradient */
#heroSection {
    background: linear-gradient(180deg,
        var(--aa-bg-page) 0%,
        rgba(220, 252, 231, 0.15) 100%) !important;
    position: relative !important;
}

/* White cards */
.bg-white.rounded-2xl,
.bg-white.rounded-xl,
.bg-white.rounded-3xl {
    background: var(--aa-bg-card) !important;
    border: 1px solid var(--aa-gray-200) !important;
    box-shadow: var(--aa-shadow-md) !important;
    transition: box-shadow var(--aa-transition-normal), transform var(--aa-transition-normal) !important;
}

.bg-white.rounded-2xl:hover,
.bg-white.rounded-xl:hover {
    box-shadow: var(--aa-shadow-lg) !important;
}

/* Amber "Why We Built This" box */
.bg-amber-50,
.bg-amber-50.border-l-4 {
    background: linear-gradient(135deg,
        var(--aa-amber-100) 0%,
        #fde68a 100%) !important;
    border-left: 4px solid var(--aa-amber-500) !important;
}

.bg-amber-50 h3,
.bg-amber-50 p,
.bg-amber-50 strong {
    color: var(--aa-gray-900) !important;
}

/* Green-to-blue gradient sections */
.bg-gradient-to-br.from-green-50.to-blue-50 {
    background: linear-gradient(135deg,
        rgba(220, 252, 231, 0.6) 0%,
        rgba(219, 234, 254, 0.6) 100%) !important;
    border: 1px solid rgba(34, 197, 94, 0.15) !important;
}

/* ============================================================
   7. TRUST HEADER BAR
   ============================================================ */

.bg-green-600.text-white {
    background: linear-gradient(90deg,
        var(--aa-green-800) 0%,
        var(--aa-green-600) 50%,
        var(--aa-green-800) 100%) !important;
    box-shadow: 0 2px 8px rgba(22, 101, 52, 0.3) !important;
}

.bg-green-600.text-white p,
.bg-green-600.text-white span {
    color: #ffffff !important;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1) !important;
}

/* ============================================================
   8. STATS SECTION - Visual Impact
   ============================================================ */

/* Big stat numbers */
.text-3xl.font-bold.text-blue-600 {
    color: var(--aa-navy-600) !important;
    font-weight: 900 !important;
    letter-spacing: -0.02em !important;
}

.text-3xl.font-bold.text-red-600 {
    color: var(--aa-red-500) !important;
    font-weight: 900 !important;
    letter-spacing: -0.02em !important;
}

.text-3xl.font-bold.text-green-600 {
    color: var(--aa-green-600) !important;
    font-weight: 900 !important;
    letter-spacing: -0.02em !important;
}

/* ============================================================
   9. PROCESS STEPS - Visual Flow
   ============================================================ */

/* Step icons */
.bg-blue-100.rounded-full,
.bg-purple-100.rounded-full,
.bg-green-100.rounded-full,
.bg-yellow-100.rounded-full {
    transition: transform var(--aa-transition-fast), box-shadow var(--aa-transition-fast) !important;
}

.bg-blue-100.rounded-full:hover,
.bg-purple-100.rounded-full:hover,
.bg-green-100.rounded-full:hover,
.bg-yellow-100.rounded-full:hover {
    transform: scale(1.1) !important;
    box-shadow: var(--aa-shadow-md) !important;
}

/* Flow arrows */
.text-gray-400.text-2xl {
    color: var(--aa-green-500) !important;
    font-weight: bold !important;
}

/* ============================================================
   10. FORM INPUTS - Professional styling
   ============================================================ */

input[type="text"],
input[type="email"],
input[type="tel"],
input[type="number"],
textarea,
select {
    border: 2px solid var(--aa-gray-300) !important;
    border-radius: var(--aa-radius-md) !important;
    padding: 0.75rem 1rem !important;
    font-size: var(--aa-text-base) !important;
    font-family: var(--aa-font-body) !important;
    background: var(--aa-bg-card) !important;
    color: var(--aa-gray-900) !important;
    transition: border-color var(--aa-transition-fast), box-shadow var(--aa-transition-fast) !important;
}

input:focus,
textarea:focus,
select:focus {
    border-color: var(--aa-green-500) !important;
    outline: none !important;
    box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.15) !important;
}

/* ============================================================
   11. PERSONAL AI TEAM - Full width layout
   ============================================================ */

.pat-container {
    background: linear-gradient(135deg,
        var(--aa-green-50) 0%,
        var(--aa-green-100) 100%) !important;
}

.pat-main-content {
    max-width: none !important;
    width: 100% !important;
    margin: 0 auto !important;
    padding: 2rem !important;
}

.pat-header {
    background: linear-gradient(135deg,
        var(--aa-green-600) 0%,
        var(--aa-green-700) 100%) !important;
}

/* ============================================================
   12. MOBILE OPTIMIZATIONS
   ============================================================ */

@media (max-width: 768px) {
    /* Larger touch targets for buttons */
    #startAppealBtn,
    button.bg-green-600,
    button.bg-green-700 {
        padding: 1rem 1.75rem !important;
        font-size: var(--aa-text-lg) !important;
        min-height: 56px !important;
        width: 100% !important;
        max-width: 350px !important;

        /* Slightly smaller 3D effect on mobile */
        box-shadow:
            0 4px 0 var(--aa-green-900),
            0 6px 10px rgba(20, 83, 45, 0.3),
            inset 0 1px 0 rgba(255, 255, 255, 0.2) !important;
    }

    #startAppealBtn:hover,
    button.bg-green-600:hover {
        transform: translateY(-2px) !important;
        box-shadow:
            0 6px 0 var(--aa-green-900),
            0 8px 14px rgba(20, 83, 45, 0.35),
            inset 0 1px 0 rgba(255, 255, 255, 0.25) !important;
    }

    #startAppealBtn:active,
    button.bg-green-600:active {
        transform: translateY(2px) !important;
        box-shadow:
            0 2px 0 var(--aa-green-900),
            0 3px 6px rgba(20, 83, 45, 0.2) !important;
    }

    /* Disable pulse animation on mobile - too distracting */
    #startAppealBtn.pulse-animation {
        animation: none !important;
    }

    /* Typography adjustments */
    h1 { font-size: var(--aa-text-3xl) !important; }
    h2 { font-size: var(--aa-text-2xl) !important; }
    h3 { font-size: var(--aa-text-xl) !important; }

    /* Stats section - stack on mobile */
    .grid.md\:grid-cols-3 {
        gap: 1.5rem !important;
    }

    /* Process steps - vertical on mobile */
    .text-gray-400.text-2xl {
        transform: rotate(90deg) !important;
        margin: 0.5rem 0 !important;
    }
}

/* ============================================================
   13. ACCESSIBILITY - Reduced Motion
   ============================================================ */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    html {
        scroll-behavior: auto !important;
    }

    #startAppealBtn.pulse-animation {
        animation: none !important;
    }
}

/* ============================================================
   14. HIGH CONTRAST MODE - Accessibility
   ============================================================ */

@media (prefers-contrast: high) {
    :root {
        --aa-gray-700: #1a1a1a;
        --aa-gray-600: #2a2a2a;
    }

    #startAppealBtn,
    button.bg-green-600,
    button.bg-green-700 {
        border: 3px solid #000000 !important;
    }
}

/* ============================================================
   15. CLEANUP - Remove competing styles
   ============================================================ */

/* Disable the old pulse animation from inline styles */
@keyframes pulse-scale {
    0%, 100% { transform: scale(1); }
}

/* Override any conflicting high-conversion.css styles */
#heroSection h1,
#heroSection .text-xl,
#heroSection .text-2xl {
    animation: none !important;
}

/* Remove old floating button styles if any remain */
.floating-start-btn {
    display: none !important;
}

/* Ensure smooth scrolling works */
html {
    scroll-behavior: smooth !important;
}

/* ==========================================================================
   CONVERSATION PANEL - FILL ALL AVAILABLE VERTICAL SPACE
   This is CRITICAL - no wasted whitespace allowed
   ========================================================================== */

.pat-conversation-panel {
    min-height: calc(90vh - 4rem) !important;
    height: 100% !important;
    display: flex !important;
    flex-direction: column !important;
}

.pat-conversation-area,
#conversationArea {
    flex: 1 1 auto !important;
    min-height: 400px !important;
    max-height: none !important; /* CRITICAL: Remove any height cap */
    height: auto !important;
}

.pat-grid-layout {
    align-items: stretch !important;
    min-height: 90vh !important;
}
