/* FirstAid LLM - Main Stylesheet */

/* ============== CSS Reset & Base ============== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
    /* Primary Colors */
    --primary: #2563EB;
    --primary-hover: #1D4ED8;
    --primary-soft: #EFF6FF;
    --primary-medium: #BFDBFE;
    
    /* Semantic Colors */
    --success: #10B981;
    --success-soft: #D1FAE5;
    --warning: #F97316;
    --warning-soft: #FFF7ED;
    --danger: #DC2626;
    --danger-soft: #FEE2E2;
    --info: #0891B2;
    --info-soft: #CFFAFE;
    
    /* Neutrals */
    --bg-app: #F8FAFC;
    --surface: #FFFFFF;
    --surface-hover: #F1F5F9;
    --border: #E2E8F0;
    --border-default: #CBD5E1;
    --border-strong: #94A3B8;
    --text-primary: #0F172A;
    --text-secondary: #475569;
    --text-muted: #94A3B8;
    --text-inverse: #FFFFFF;
    
    /* Spacing */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    --space-2xl: 48px;
    --space-3xl: 64px;
    
    /* Borders */
    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 9999px;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-hover: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
    font-size: 16px;
    line-height: 1.5;
    color: var(--text-primary);
    background-color: var(--bg-app);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ============== Typography ============== */

h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    line-height: 1.2;
    color: var(--text-primary);
    margin-bottom: var(--space-md);
}

h1 { font-size: 2.5rem; }
h2 { font-size: 2rem; }
h3 { font-size: 1.75rem; }
h4 { font-size: 1.5rem; }
h5 { font-size: 1.25rem; }
h6 { font-size: 1rem; }

p {
    margin-bottom: var(--space-md);
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: color 0.2s ease;
}

a:hover {
    color: var(--primary-hover);
    text-decoration: underline;
}

/* ============== Layout ============== */

.container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 var(--space-lg);
}

.container-narrow {
    max-width: 960px;
    margin: 0 auto;
    padding: 0 var(--space-lg);
}

.container-wide {
    max-width: 1440px;
    margin: 0 auto;
    padding: 0 var(--space-lg);
}

/* ============== Header/Navigation ============== */

.header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: var(--space-md) 0;
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: var(--shadow-sm);
}

.header-brand {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    margin-bottom: var(--space-sm);
}

.header-logo {
    width: 44px;
    height: 44px;
    object-fit: contain;
}

.header-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.header-tagline {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin: 0;
}

.nav {
    display: flex;
    gap: var(--space-sm);
    margin-top: var(--space-md);
}

.nav-link {
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    font-weight: 500;
    font-size: 0.875rem;
    color: var(--text-secondary);
    transition: all 0.2s ease;
    border: 2px solid transparent;
}

.nav-link:hover {
    color: var(--primary);
    background: var(--primary-soft);
    text-decoration: none;
}

.nav-link.active {
    color: var(--primary);
    background: var(--primary-soft);
    border-color: var(--primary-medium);
}

/* ============== Icons ============== */

i.fas, i.fa, i.far, i.fab {
    display: inline-block;
    margin-right: 8px;
    font-style: normal;
    font-variant: normal;
    text-rendering: auto;
    line-height: 1;
    -webkit-font-smoothing: antialiased;
}

.nav-link i {
    font-size: 1rem;
}

/* ============== Buttons ============== */

.btn {
    display: inline-block;
    padding: 12px 24px;
    font-size: 1rem;
    font-weight: 500;
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
    text-decoration: none;
    font-family: inherit;
}

.btn-primary {
    background: var(--primary);
    color: var(--text-inverse);
    box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
    background: var(--primary-hover);
    box-shadow: var(--shadow-md);
    text-decoration: none;
}

.btn-secondary {
    background: transparent;
    color: var(--primary);
    border: 2px solid var(--primary);
}

.btn-secondary:hover {
    background: var(--primary-soft);
    text-decoration: none;
}

.btn-lg {
    padding: 16px 32px;
    font-size: 1.125rem;
}

.btn-sm {
    padding: 8px 16px;
    font-size: 0.875rem;
}

/* ============== Cards ============== */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: var(--space-lg);
    box-shadow: var(--shadow-sm);
    transition: all 0.2s ease;
}

.card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.card-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: var(--space-sm);
}

.card-body {
    color: var(--text-secondary);
}

/* ============== Forms ============== */

.form-group {
    margin-bottom: var(--space-lg);
}

.form-label {
    display: block;
    font-weight: 500;
    font-size: 0.875rem;
    color: var(--text-primary);
    margin-bottom: var(--space-sm);
}

.form-input,
.form-textarea {
    width: 100%;
    padding: 12px 16px;
    font-size: 1rem;
    font-family: inherit;
    color: var(--text-primary);
    background: var(--surface);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    transition: all 0.2s ease;
}

.form-input:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-soft);
}

.form-textarea {
    resize: vertical;
    min-height: 120px;
}

/* ============== Chat Interface ============== */

.chat-container {
    max-width: 960px;
    margin: var(--space-2xl) auto;
}

.chat-messages {
    margin-bottom: var(--space-xl);
    max-height: 600px;
    overflow-y: auto;
    padding: var(--space-lg);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
}

.message {
    margin-bottom: var(--space-lg);
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

.message-user {
    align-items: flex-end;
}

.message-assistant {
    align-items: flex-start;
}

.message-content {
    max-width: 80%;
    padding: var(--space-md);
    border-radius: var(--radius-md);
    display: block !important;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.message-user .message-content {
    background: var(--primary-soft);
    border: 1px solid var(--primary-medium);
    color: var(--text-primary);
}

.message-assistant .message-content {
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    color: var(--text-primary);
}

/* Formatted lists in message content */
.message-content ol,
.message-content ul {
    margin: var(--space-md) 0;
    padding-left: 1.5rem;
    line-height: 1.8;
}

.message-content ol {
    counter-reset: item;
    list-style: none;
    padding-left: 0;
}

.message-content ol > li {
    counter-increment: item;
    margin-bottom: var(--space-sm);
    padding-left: 2rem;
    position: relative;
}

.message-content ol > li::before {
    content: counter(item);
    position: absolute;
    left: 0;
    top: 0;
    background: var(--primary);
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 600;
}

.message-content ul > li {
    margin-bottom: var(--space-sm);
    padding-left: var(--space-sm);
}

.message-content ul > li::marker {
    color: var(--primary);
}

.message-content strong {
    color: var(--text-primary);
    font-weight: 600;
}

.message-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0 var(--space-xs);
}

.message-user .message-label {
    text-align: right;
}

/* ============== Alerts ============== */

.alert {
    padding: var(--space-md);
    border-radius: var(--radius-sm);
    margin-bottom: var(--space-lg);
    border-left: 4px solid;
}

.alert ul {
    margin: var(--space-sm) 0;
    padding-left: 1.5rem;
}

.alert li {
    margin-bottom: var(--space-xs);
}

.alert-info {
    background: var(--info-soft);
    border-color: var(--info);
    color: #0E7490;
}

.alert-success {
    background: var(--success-soft);
    border-color: var(--success);
    color: #047857;
}

.alert-warning {
    background: var(--warning-soft);
    border-color: var(--warning);
    color: #C2410C;
}

.alert-danger {
    background: var(--danger-soft);
    border-color: var(--danger);
    color: #991B1B;
}

/* ============== Utilities ============== */

.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-muted); }
.text-primary { color: var(--primary); }

.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mt-xl { margin-top: var(--space-xl); }

.mb-sm { margin-bottom: var(--space-sm); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }
.mb-xl { margin-bottom: var(--space-xl); }

/* Card content spacing */
.card ul,
.card ol {
    padding-left: 24px;
    margin-left: 12px;
}

.d-flex { display: flex; }
.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }
.gap-lg { gap: var(--space-lg); }

.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }

/* ============== Grid ============== */

.grid {
    display: grid;
    gap: var(--space-lg);
}

.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 768px) {
    .grid-2, .grid-3, .grid-4 {
        grid-template-columns: 1fr;
    }
}

/* ============== Toast Notifications ============== */

.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: 400px;
}

.toast {
    background: var(--surface);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    padding: 16px 20px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    animation: slideIn 0.3s ease-out;
    border-left: 4px solid var(--primary);
}

.toast.success {
    border-left-color: var(--success);
}

.toast.error {
    border-left-color: var(--danger);
}

.toast.warning {
    border-left-color: var(--warning);
}

.toast-icon {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
}

.toast-icon svg {
    width: 100%;
    height: 100%;
}

.toast.success .toast-icon {
    color: var(--success);
}

.toast.error .toast-icon {
    color: var(--danger);
}

.toast.warning .toast-icon {
    color: var(--warning);
}

.toast-content {
    flex: 1;
}

.toast-title {
    font-weight: 600;
    margin-bottom: 4px;
    color: var(--text-primary);
}

.toast-message {
    font-size: 0.875rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

.toast-close {
    flex-shrink: 0;
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    color: var(--text-muted);
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    transition: all 0.2s;
}

.toast-close:hover {
    background: var(--surface-hover);
    color: var(--text-primary);
}

@keyframes slideIn {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(400px);
        opacity: 0;
    }
}

.toast.removing {
    animation: slideOut 0.3s ease-out forwards;
}

/* ============== Modal ============== */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.modal-overlay.modal-show {
    opacity: 1;
}

.modal-overlay.modal-closing {
    opacity: 0;
}

.modal-box {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    max-width: 400px;
    width: 90%;
    padding: var(--space-xl);
    transform: scale(0.95);
    transition: transform 0.2s ease;
}

.modal-show .modal-box {
    transform: scale(1);
}

.modal-content {
    margin-bottom: var(--space-lg);
}

.modal-content p {
    font-size: 1rem;
    color: var(--text-primary);
    margin: 0;
}

.modal-actions {
    display: flex;
    gap: var(--space-sm);
    justify-content: flex-end;
}

/* ============== Icons ============== */

.icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
}

.icon-sm {
    width: 16px;
    height: 16px;
}

.icon-lg {
    width: 24px;
    height: 24px;
}

.icon-xl {
    width: 32px;
    height: 32px;
}

.icon svg {
    width: 100%;
    height: 100%;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    fill: none;
}

/* ============== Footer ============== */

.footer {
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding: var(--space-2xl) 0;
    margin-top: var(--space-3xl);
}

.footer-content {
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* ============== Loading Spinner ============== */

.spinner {
    border: 3px solid var(--border);
    border-top: 3px solid var(--primary);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: var(--space-xl) auto;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-text {
    text-align: center;
    color: var(--text-muted);
    margin-top: var(--space-md);
}

/* ============== Voice Input ============== */

#voice-btn {
    flex-shrink: 0;
    border-color: var(--text-muted);
    color: var(--text-muted);
}

#voice-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-soft);
}

#voice-btn.active {
    background: var(--danger);
    color: var(--text-inverse);
    border-color: var(--danger);
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
        box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.7);
    }
    50% {
        box-shadow: 0 0 0 8px rgba(220, 38, 38, 0.2);
    }
}

@keyframes pulse-dot {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

#voice-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
}

#voice-status i {
    animation: pulse 1s infinite;
}

