/**
 * GasConsult.ai - Main Stylesheet
 * Week 2 Performance Optimization: Extracted from inline styles
 * Reduces page payload by ~46KB and enables browser caching
 */

/* ============================================================================
   CSS VARIABLES (Design Tokens)
   ============================================================================ */
:root {
    /* Colors - Gray Scale */
    --gray-50: #F9FAFB;
    --gray-100: #F3F4F6;
    --gray-200: #E5E7EB;
    --gray-300: #D1D5DB;
    --gray-400: #9CA3AF;
    --gray-500: #6B7280;
    --gray-600: #4B5563;
    --gray-700: #374151;
    --gray-800: #1F2937;
    --gray-900: #111827;

    /* Colors - Blue Scale */
    --blue-50: #EFF6FF;
    --blue-100: #DBEAFE;
    --blue-200: #BFDBFE;
    --blue-300: #93C5FD;
    --blue-400: #60A5FA;
    --blue-500: #3B82F6;
    --blue-600: #2563EB;
    --blue-700: #1D4ED8;
    --blue-800: #1E40AF;
    --blue-900: #1E3A8A;

    /* Semantic Colors */
    --white: #FFFFFF;
    --black: #000000;
    --green: #10B981;
    --yellow: #FBBF24;
    --red: #EF4444;

    /* Spacing */
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 16px;
    --spacing-lg: 24px;
    --spacing-xl: 32px;

    /* Border Radius */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-2xl: 24px;

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

/* ============================================================================
   GLOBAL RESETS & BASE STYLES
   ============================================================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(180deg, #F0F7FF 0%, var(--gray-50) 50%, #FAFBFF 100%);
    color: var(--gray-900);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    min-height: 100vh;
}

a {
    text-decoration: none;
    color: inherit;
}

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    background: none;
}

/* ============================================================================
   NAVIGATION
   ============================================================================ */
.nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: transparent;  /* Keep transparent for glassmorphism effect */
    padding: 12px 20px;
}

.nav-inner {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.nav-logo {
    font-size: 18px;
    font-weight: 700;
    color: var(--gray-900);
    letter-spacing: -0.5px;
}

.nav-links {
    display: none;
    align-items: center;
    gap: 24px;
}

.nav-link {
    font-size: 14px;
    font-weight: 500;
    color: var(--gray-600);
    transition: color 0.2s;
}

.nav-link:hover {
    color: var(--blue-600);
}

.nav-link.active {
    color: var(--blue-600);
}

/* ============================================================================
   BUTTONS
   ============================================================================ */
.btn-primary {
    padding: 10px 20px;
    background: linear-gradient(135deg, var(--blue-600) 0%, var(--blue-700) 100%);
    color: white;
    border-radius: var(--radius-lg);
    font-size: 14px;
    font-weight: 600;
    transition: all 0.2s;
    box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    padding: 10px 20px;
    background: white;
    color: var(--gray-700);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    font-size: 14px;
    font-weight: 600;
    transition: all 0.2s;
}

.btn-secondary:hover {
    background: var(--gray-50);
    border-color: var(--gray-300);
}

/* ============================================================================
   EVIDENCE BADGES
   ============================================================================ */
.evidence-badge {
    display: inline-flex;
    align-items: center;
    padding: 10px 16px;
    border-radius: var(--radius-lg);
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 16px;
    border: 1px solid;
    transition: all 0.2s;
}

.evidence-badge.high {
    background: linear-gradient(135deg, #ECFDF5 0%, #D1FAE5 100%);
    border-color: #86EFAC;
    color: #065F46;
}

.evidence-badge.moderate {
    background: linear-gradient(135deg, #FFFBEB 0%, #FEF3C7 100%);
    border-color: #FDE68A;
    color: #92400E;
}

.evidence-badge.low {
    background: linear-gradient(135deg, #FEF2F2 0%, #FEE2E2 100%);
    border-color: #FCA5A5;
    color: #991B1B;
}

.evidence-badge.interactive-badge {
    cursor: pointer;
}

.evidence-badge.interactive-badge:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* ============================================================================
   MESSAGES
   ============================================================================ */
.message {
    margin-bottom: 24px;
    animation: fadeIn 0.3s ease;
}

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

.message-bubble {
    padding: 20px 24px;
    border-radius: var(--radius-xl);
    background: white;
    box-shadow: var(--shadow-sm);
}

.user-message .message-bubble {
    background: linear-gradient(135deg, var(--blue-600) 0%, var(--blue-700) 100%);
    color: white;
    margin-left: auto;
    max-width: 80%;
}

.ai-message .message-bubble {
    background: white;
    border: 1px solid var(--gray-200);
}

/* ============================================================================
   FORM INPUTS
   ============================================================================ */
.chat-input {
    flex: 1;
    border: none;
    outline: none;
    padding: 0 12px;
    font-size: 15px;
    font-family: inherit;
    color: var(--gray-800);
    background: transparent;
    resize: none;
    min-height: 44px;  /* WCAG AA compliance */
}

.chat-input::placeholder {
    color: var(--gray-400);
}

.chat-send {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--blue-600) 0%, var(--blue-700) 100%);
    color: white;
    border-radius: var(--radius-lg);
    transition: all 0.2s;
    flex-shrink: 0;
}

.chat-send:hover {
    transform: scale(1.05);
    box-shadow: var(--shadow-md);
}

/* ============================================================================
   HINT CHIPS
   ============================================================================ */
.chat-hints {
    display: grid;
    grid-template-columns: repeat(2, 1fr);  /* 2 columns on mobile */
    gap: 6px;
    padding: 8px;
    max-width: 100%;
}

.hint-chip {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 5px;
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: 10px;
    padding: 6px 8px;
    min-height: 44px;  /* WCAG AA compliance */
    font-size: 9.5px;
    font-weight: 500;
    color: var(--gray-700);
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
    line-height: 1.25;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.hint-chip:hover {
    background: var(--blue-50);
    border-color: var(--blue-400);
    color: var(--blue-700);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.hint-chip svg {
    width: 12px;
    height: 12px;
    flex-shrink: 0;
}

/* ============================================================================
   LOADING STATES
   ============================================================================ */
.skeleton-loader {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.skeleton-line {
    height: 16px;
    background: linear-gradient(90deg, #E5E7EB 0%, #F3F4F6 50%, #E5E7EB 100%);
    background-size: 200% 100%;
    border-radius: 4px;
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.streaming-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--gray-500);
    margin-top: 12px;
}

.streaming-dots {
    display: flex;
    gap: 4px;
}

.streaming-dots span {
    width: 6px;
    height: 6px;
    background: var(--blue-500);
    border-radius: 50%;
    animation: pulse 1.4s infinite;
}

.streaming-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.streaming-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes pulse {
    0%, 100% { opacity: 0.4; transform: scale(0.8); }
    50% { opacity: 1; transform: scale(1); }
}

/* ============================================================================
   RESPONSIVE BREAKPOINTS
   ============================================================================ */

/* Very small screens */
@media (max-width: 360px) {
    .chat-hints {
        grid-template-columns: 1fr;
    }
}

/* Tablet */
@media (min-width: 768px) {
    .nav {
        padding: 14px 32px;
    }

    .nav-links {
        display: flex;
    }

    .chat-hints {
        grid-template-columns: repeat(3, 1fr);  /* 3 columns on tablet */
        gap: 10px;
        padding: 18px 10px 8px;
    }
}

/* Desktop */
@media (min-width: 1024px) {
    .nav {
        padding: 16px 40px;
    }

    .chat-input {
        padding: 12px 16px;
        min-height: 44px;
        max-height: 160px;
    }

    .chat-send {
        width: 48px;
        height: 48px;
        border-radius: 14px;
        margin: 6px;
    }

    .chat-hints {
        grid-template-columns: repeat(5, 1fr);  /* 5 columns on desktop */
        padding: 20px 12px 8px;
    }

    .hint-chip {
        padding: 12px 20px;
    }
}

/* Large desktop */
@media (min-width: 1280px) {
    .nav {
        padding: 16px 48px;
    }
}

/* ============================================================================
   CITATION PREVIEW (Week 3 Innovation Feature)
   ============================================================================ */
.citation-preview-trigger {
    cursor: pointer;
    position: relative;
    user-select: none;
    transition: all 0.2s ease;
}

.citation-preview-trigger:hover {
    background: var(--blue-500);
    transform: scale(1.1);
}

.citation-preview-popup {
    position: fixed;
    z-index: 10000;
    background: white;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    max-width: 500px;
    max-height: 400px;
    overflow-y: auto;
    padding: 20px;
    animation: popupFadeIn 0.2s ease;
}

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

.citation-preview-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--gray-200);
}

.citation-preview-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--gray-900);
    line-height: 1.4;
    flex: 1;
}

.citation-preview-close {
    width: 28px;
    height: 28px;
    min-width: 28px;
    background: var(--gray-100);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--gray-600);
}

.citation-preview-close:hover {
    background: var(--gray-200);
    color: var(--gray-900);
}

.citation-preview-pmid {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--blue-50);
    color: var(--blue-700);
    padding: 6px 12px;
    border-radius: var(--radius-md);
    font-size: 12px;
    font-weight: 600;
    text-decoration: none;
    margin-bottom: 16px;
    transition: all 0.2s;
}

.citation-preview-pmid:hover {
    background: var(--blue-100);
    color: var(--blue-800);
}

.citation-preview-abstract {
    font-size: 14px;
    line-height: 1.7;
    color: var(--gray-700);
    text-align: justify;
}

.citation-preview-abstract-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--gray-500);
    margin-bottom: 8px;
}

.citation-preview-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9999;
    background: rgba(0, 0, 0, 0.3);
    animation: overlayFadeIn 0.2s ease;
}

@keyframes overlayFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Mobile optimization */
@media (max-width: 768px) {
    .citation-preview-popup {
        position: fixed;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        width: calc(100vw - 32px);
        max-width: none;
        max-height: calc(100vh - 80px);
    }
}

/* Desktop optimization */
@media (min-width: 769px) {
    .citation-preview-popup {
        width: 500px;
    }
}

/* ============================================================================
   PDF EXPORT BUTTON (Week 3 Innovation Feature)
   ============================================================================ */
.export-pdf-btn {
    position: fixed;
    bottom: 100px;
    right: 24px;
    z-index: 900;
    background: linear-gradient(135deg, var(--blue-600) 0%, var(--blue-700) 100%);
    color: white;
    padding: 12px 20px;
    border-radius: var(--radius-lg);
    font-size: 14px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: var(--shadow-lg);
    transition: all 0.2s;
    cursor: pointer;
    border: none;
}

.export-pdf-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-xl);
}

.export-pdf-btn svg {
    width: 18px;
    height: 18px;
}

.export-pdf-btn.exporting {
    opacity: 0.7;
    pointer-events: none;
}

.export-pdf-btn.exporting svg {
    animation: spin 1s linear infinite;
}

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

@media (max-width: 768px) {
    .export-pdf-btn {
        bottom: 80px;
        right: 16px;
        padding: 10px 16px;
        font-size: 13px;
    }
}

/* ============================================================================
   EVIDENCE QUALITY CHART (Week 3 Innovation Feature)
   ============================================================================ */
.evidence-chart-popup {
    position: fixed;
    z-index: 10000;
    background: white;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    width: 450px;
    max-width: calc(100vw - 32px);
    padding: 24px;
    animation: popupFadeIn 0.2s ease;
}

.evidence-chart-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--gray-200);
}

.evidence-chart-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--gray-900);
}

.evidence-chart-close {
    width: 28px;
    height: 28px;
    background: var(--gray-100);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--gray-600);
}

.evidence-chart-close:hover {
    background: var(--gray-200);
    color: var(--gray-900);
}

.evidence-chart-bars {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.chart-bar-row {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.chart-bar-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-700);
}

.chart-bar-count {
    font-size: 12px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    background: var(--gray-100);
    color: var(--gray-600);
}

.chart-bar-track {
    width: 100%;
    height: 20px;
    background: var(--gray-100);
    border-radius: var(--radius-md);
    overflow: hidden;
    position: relative;
}

.chart-bar-fill {
    height: 100%;
    border-radius: var(--radius-md);
    transition: width 0.4s ease;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 8px;
}

.chart-bar-percentage {
    font-size: 11px;
    font-weight: 700;
    color: white;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

/* Study type colors */
.chart-bar-fill.guideline {
    background: linear-gradient(135deg, #10B981 0%, #059669 100%);
}

.chart-bar-fill.meta-analysis {
    background: linear-gradient(135deg, #3B82F6 0%, #2563EB 100%);
}

.chart-bar-fill.systematic-review {
    background: linear-gradient(135deg, #8B5CF6 0%, #7C3AED 100%);
}

.chart-bar-fill.rct {
    background: linear-gradient(135deg, #F59E0B 0%, #D97706 100%);
}

.chart-bar-fill.observational {
    background: linear-gradient(135deg, #6B7280 0%, #4B5563 100%);
}

.evidence-chart-summary {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--gray-200);
    font-size: 13px;
    color: var(--gray-600);
    line-height: 1.6;
}

.evidence-chart-summary strong {
    color: var(--gray-900);
}

@media (max-width: 768px) {
    .evidence-chart-popup {
        position: fixed;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        width: calc(100vw - 32px);
    }
}

@media (min-width: 769px) {
    .evidence-chart-popup {
        width: 450px;
    }
}

/* ============================================================================
   UTILITIES
   ============================================================================ */
.text-center {
    text-align: center;
}

.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mt-4 { margin-top: 32px; }

.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.mb-4 { margin-bottom: 32px; }

.hidden {
    display: none;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}
