/* ═══════════════════════════════════════════════════════════════════════════
   AI SQL Analyst — Premium Light-Mode Design System (Green Accent)
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Reset & Variables ──────────────────────────────────────────────────── */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Palette — clean white + green */
    --bg-primary: #ffffff;
    --bg-secondary: #f8faf9;
    --bg-card: rgba(255, 255, 255, 0.85);
    --bg-card-hover: rgba(255, 255, 255, 0.95);
    --border-subtle: rgba(16, 185, 129, 0.18);
    --border-glow: rgba(16, 185, 129, 0.35);

    --text-primary: #1e293b;
    --text-secondary: #475569;
    --text-muted: #94a3b8;

    --accent-green: #10b981;
    --accent-green-dark: #059669;
    --accent-green-light: #34d399;
    --accent-emerald: #047857;
    --accent-teal: #0d9488;
    --accent-cyan: #06b6d4;
    --accent-amber: #f59e0b;
    --accent-rose: #f43f5e;

    --gradient-primary: linear-gradient(135deg, #10b981 0%, #059669 50%, #047857 100%);
    --gradient-subtle: linear-gradient(135deg, rgba(16, 185, 129, 0.06) 0%, rgba(5, 150, 105, 0.04) 100%);

    /* Typography */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

    /* Sizes */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;

    /* Transitions */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-smooth: 300ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-spring: 500ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-sans);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

/* ── Background Effects ─────────────────────────────────────────────────── */

.bg-effects {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(120px);
    opacity: 0.08;
    animation: orbFloat 20s ease-in-out infinite;
}

.orb-1 {
    width: 600px;
    height: 600px;
    background: var(--accent-green);
    top: -200px;
    left: -100px;
    animation-duration: 25s;
}

.orb-2 {
    width: 500px;
    height: 500px;
    background: var(--accent-teal);
    top: 50%;
    right: -150px;
    animation-duration: 30s;
    animation-delay: -5s;
}

.orb-3 {
    width: 400px;
    height: 400px;
    background: var(--accent-green-light);
    bottom: -100px;
    left: 30%;
    animation-duration: 22s;
    animation-delay: -10s;
}

@keyframes orbFloat {
    0%, 100% { transform: translate(0, 0) scale(1); }
    25%      { transform: translate(40px, -30px) scale(1.05); }
    50%      { transform: translate(-20px, 40px) scale(0.95); }
    75%      { transform: translate(30px, 20px) scale(1.02); }
}

/* ── Container ──────────────────────────────────────────────────────────── */

.container {
    position: relative;
    z-index: 1;
    max-width: 1100px;
    margin: 0 auto;
    padding: 2rem 1.5rem 4rem;
}

/* ── Glass Card Base ────────────────────────────────────────────────────── */

.glass {
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04), 0 4px 12px rgba(16, 185, 129, 0.04);
    transition: border-color var(--transition-smooth), box-shadow var(--transition-smooth);
}

.glass:hover {
    border-color: var(--border-glow);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05), 0 8px 24px rgba(16, 185, 129, 0.08);
}

/* ── Header ─────────────────────────────────────────────────────────────── */

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.logo {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.logo-icon {
    width: 48px;
    height: 48px;
    background: var(--gradient-primary);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    box-shadow: 0 4px 16px rgba(16, 185, 129, 0.3);
}

.logo-icon svg {
    width: 26px;
    height: 26px;
}

.header h1 {
    font-size: 1.6rem;
    font-weight: 800;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.02em;
}

.tagline {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 400;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

/* ── Model Switcher ─────────────────────────────────────────────────────── */

.model-switcher {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.switcher-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 600;
}

.switcher-track {
    display: flex;
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-xl);
    padding: 3px;
    gap: 2px;
}

.switcher-btn {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.45rem 1rem;
    border: none;
    border-radius: var(--radius-xl);
    background: transparent;
    color: var(--text-muted);
    font-family: var(--font-sans);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.switcher-btn:hover {
    color: var(--text-secondary);
}

.switcher-btn.active {
    background: var(--gradient-primary);
    color: white;
    box-shadow: 0 2px 10px rgba(16, 185, 129, 0.3);
}

.btn-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    opacity: 0.6;
}

.switcher-btn.active .btn-dot {
    background: #a7f3d0;
    opacity: 1;
    box-shadow: 0 0 6px #a7f3d0;
    animation: dotPulse 2s ease-in-out infinite;
}

@keyframes dotPulse {
    0%, 100% { box-shadow: 0 0 4px #a7f3d0; }
    50%      { box-shadow: 0 0 12px #a7f3d0; }
}

/* ── Input Section ──────────────────────────────────────────────────────── */

.input-section {
    margin-bottom: 2rem;
}

.input-card {
    padding: 1.5rem;
}

.input-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
    letter-spacing: 0.02em;
}

.input-wrapper {
    display: flex;
    gap: 0.75rem;
    align-items: flex-end;
}

textarea {
    flex: 1;
    resize: vertical;
    min-height: 70px;
    max-height: 200px;
    padding: 1rem 1.25rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 0.95rem;
    line-height: 1.6;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

textarea::placeholder {
    color: var(--text-muted);
}

textarea:focus {
    outline: none;
    border-color: var(--accent-green);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15);
}

.submit-btn {
    width: 52px;
    height: 52px;
    flex-shrink: 0;
    border: none;
    border-radius: var(--radius-md);
    background: var(--gradient-primary);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.3);
}

.submit-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 25px rgba(16, 185, 129, 0.4);
}

.submit-btn:active {
    transform: translateY(0);
}

.submit-btn svg {
    width: 22px;
    height: 22px;
}

.submit-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* ── Loading ────────────────────────────────────────────────────────────── */

.loading {
    text-align: center;
    padding: 3rem 1rem;
}

.loading-content {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 1.25rem;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 3px solid rgba(16, 185, 129, 0.15);
    border-top-color: var(--accent-green);
    border-right-color: var(--accent-green-dark);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.loading-text {
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.loading-steps {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-wrap: wrap;
    justify-content: center;
}

.loading-steps .step {
    font-size: 0.7rem;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    background: rgba(16, 185, 129, 0.06);
    color: var(--text-muted);
    font-weight: 500;
    transition: all var(--transition-smooth);
}

.loading-steps .step.active {
    background: rgba(16, 185, 129, 0.15);
    color: var(--accent-green-dark);
}

.loading-steps .step-arrow {
    color: var(--text-muted);
    font-size: 0.65rem;
    opacity: 0.4;
}

/* ── Results Section ────────────────────────────────────────────────────── */

.results-section {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    animation: fadeInUp 0.5s ease;
}

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

.result-card {
    padding: 1.5rem;
}

.card-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.card-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.card-icon svg {
    width: 18px;
    height: 18px;
}

.sql-icon     { background: rgba(16, 185, 129, 0.1); color: var(--accent-green-dark); }
.data-icon    { background: rgba(6, 182, 212, 0.1);  color: var(--accent-teal); }
.answer-icon  { background: rgba(16, 185, 129, 0.1); color: var(--accent-green); }
.insights-icon{ background: rgba(245, 158, 11, 0.1); color: var(--accent-amber); }
.error-icon   { background: rgba(244, 63, 94, 0.1);  color: var(--accent-rose); }

.card-header h2 {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
    flex: 1;
    letter-spacing: -0.01em;
}

.copy-btn {
    width: 34px;
    height: 34px;
    border: 1px solid var(--border-subtle);
    background: transparent;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.copy-btn svg {
    width: 16px;
    height: 16px;
}

.copy-btn:hover {
    border-color: var(--accent-green);
    color: var(--accent-green);
    background: rgba(16, 185, 129, 0.06);
}

.row-count {
    font-size: 0.75rem;
    color: var(--accent-green-dark);
    padding: 0.2rem 0.6rem;
    background: rgba(16, 185, 129, 0.08);
    border-radius: var(--radius-xl);
    font-weight: 500;
}

/* ── SQL Code Block ─────────────────────────────────────────────────────── */

.sql-code {
    background: #f0fdf4;
    border: 1px solid rgba(16, 185, 129, 0.15);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    overflow-x: auto;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    line-height: 1.7;
    color: var(--accent-emerald);
    tab-size: 2;
}

/* ── Data Table ─────────────────────────────────────────────────────────── */

.table-wrapper {
    overflow-x: auto;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    max-height: 500px;
    overflow-y: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

thead {
    position: sticky;
    top: 0;
    z-index: 2;
}

th {
    background: rgba(16, 185, 129, 0.08);
    color: var(--accent-green-dark);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.7rem;
    letter-spacing: 0.06em;
    padding: 0.75rem 1rem;
    text-align: left;
    white-space: nowrap;
    border-bottom: 1px solid var(--border-subtle);
}

td {
    padding: 0.65rem 1rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.04);
    color: var(--text-secondary);
    white-space: nowrap;
}

tr:hover td {
    background: rgba(16, 185, 129, 0.03);
    color: var(--text-primary);
}

/* ── Answer & Insights ──────────────────────────────────────────────────── */

.answer-text {
    font-size: 0.95rem;
    line-height: 1.75;
    color: var(--text-secondary);
}

.insights-text {
    font-size: 0.9rem;
    line-height: 1.75;
    color: var(--text-secondary);
    white-space: pre-wrap;
}

/* ── Error ──────────────────────────────────────────────────────────────── */

.error-card {
    border-color: rgba(244, 63, 94, 0.25) !important;
}

.error-text {
    font-size: 0.9rem;
    line-height: 1.7;
    color: var(--accent-rose);
}

/* ── Utilities ──────────────────────────────────────────────────────────── */

.hidden {
    display: none !important;
}

/* ── Responsive ─────────────────────────────────────────────────────────── */

@media (max-width: 640px) {
    .container {
        padding: 1rem;
    }

    .header {
        flex-direction: column;
        align-items: flex-start;
    }

    .header h1 {
        font-size: 1.3rem;
    }

    .input-wrapper {
        flex-direction: column;
    }

    .submit-btn {
        width: 100%;
        height: 48px;
    }

    .loading-steps {
        gap: 0.2rem;
    }

    .loading-steps .step-arrow {
        display: none;
    }
}
