@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
    --font-heading: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-body: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;

    /* Light Theme */
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-card: #ffffff;
    --bg-sidebar: #ffffff;
    --bg-hover: #f1f5f9;
    --border: #e2e8f0;
    --border-hover: #cbd5e1;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --text-sub: #94a3b8;

    --brand: #2563eb;
    --brand-hover: #1d4ed8;
    --brand-light: rgba(37, 99, 235, 0.1);

    --accent-blue: #0ea5e9;
    --accent-emerald: #10b981;
    --accent-amber: #f59e0b;
    --accent-rose: #f43f5e;
    --accent-purple: #8b5cf6;
}

.dark {
    /* Dark Theme - Deep Sapphire & Slate */
    --bg-primary: #070b14;
    --bg-secondary: #0b1120;
    --bg-card: #0f172a;
    --bg-sidebar: #0a0f1d;
    --bg-hover: #1e293b;
    --border: #1e293b;
    --border-hover: #334155;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --text-sub: #64748b;

    --brand: #3b82f6;
    --brand-hover: #2563eb;
    --brand-light: rgba(59, 130, 246, 0.18);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: var(--font-body);
}

h1, h2, h3, h4, h5, h6, .font-heading {
    font-family: var(--font-heading);
    letter-spacing: -0.02em;
}

code, pre, .font-mono {
    font-family: var(--font-mono);
}

body {
    background-color: var(--bg-primary);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    transition: background-color 0.2s ease, color 0.2s ease;
}

/* Master Layout Grid for Zero-Overlap */
.app-wrapper {
    display: flex;
    flex: 1;
    min-height: calc(100vh - 61px);
    position: relative;
}

.app-sidebar {
    width: 260px;
    flex-shrink: 0;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 1.25rem;
    z-index: 30;
}

.app-main {
    flex: 1;
    min-width: 0;
    overflow-y: auto;
    padding: 1.5rem;
    background: var(--bg-primary);
}

@media (max-width: 768px) {
    .app-sidebar {
        position: fixed;
        top: 0;
        bottom: 0;
        left: 0;
        z-index: 50;
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    }

    .app-sidebar.open {
        transform: translateX(0);
    }

    .app-main {
        padding: 1rem;
    }
}

/* Glassmorphism & Cards */
.glass-panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 1.25rem;
    box-shadow: 0 4px 20px -2px rgba(0, 0, 0, 0.05);
    backdrop-filter: blur(12px);
    transition: all 0.2s ease;
}

.dark .glass-panel {
    box-shadow: 0 10px 30px -5px rgba(0, 0, 0, 0.35);
}

.card-hover {
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.card-hover:hover {
    transform: translateY(-2px);
    border-color: rgba(99, 102, 241, 0.4);
    box-shadow: 0 12px 28px -5px rgba(99, 102, 241, 0.15);
}

/* Modern Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.6rem 1.15rem;
    border-radius: 0.75rem;
    font-size: 0.875rem;
    font-weight: 600;
    transition: all 0.15s ease;
    cursor: pointer;
    border: 1px solid transparent;
    text-decoration: none;
}

.btn:active {
    transform: scale(0.98);
}

.btn-primary {
    background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
    color: #ffffff;
    box-shadow: 0 4px 14px rgba(99, 102, 241, 0.35);
}

.btn-primary:hover {
    background: linear-gradient(135deg, #4f46e5 0%, #4338ca 100%);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.45);
}

.btn-secondary {
    background: var(--bg-hover);
    color: var(--text-main);
    border: 1px solid var(--border);
}

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

.btn-danger {
    background: #f43f5e;
    color: #ffffff;
}

.btn-danger:hover {
    background: #e11d48;
}

.btn-test {
    background: rgba(14, 165, 233, 0.12);
    color: #38bdf8;
    border: 1px solid rgba(14, 165, 233, 0.3);
}

.btn-test:hover {
    background: rgba(14, 165, 233, 0.25);
}

/* Nav Item styling */
.nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 0.85rem;
    border-radius: 0.75rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-muted);
    transition: all 0.15s ease;
    text-decoration: none;
}

.nav-link:hover {
    background: var(--bg-hover);
    color: var(--text-main);
}

.nav-link.active {
    background: var(--brand-light);
    color: var(--brand);
    font-weight: 600;
}

.dark .nav-link.active {
    color: #818cf8;
}

/* Custom Scrollbars */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 9999px;
}

.dark ::-webkit-scrollbar-thumb {
    background: #334155;
}

::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Floating Toast Notifications */
#toast-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 99999;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    pointer-events: none;
}

.toast {
    pointer-events: auto;
    min-width: 280px;
    max-width: 400px;
    padding: 0.85rem 1.15rem;
    border-radius: 0.85rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-main);
    box-shadow: 0 20px 30px -5px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.875rem;
    animation: toastSlideIn 0.25s ease-out;
}

@keyframes toastSlideIn {
    from { opacity: 0; transform: translateY(12px) scale(0.96); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.toast-success { border-left: 4px solid #10b981; }
.toast-error   { border-left: 4px solid #f43f5e; }
.toast-info    { border-left: 4px solid #0ea5e9; }

/* Modals */
.modal-backdrop {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(6px);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.modal-backdrop.open {
    display: flex;
    opacity: 1;
}

.modal-content {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 1.25rem;
    width: 100%;
    max-width: 580px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    transform: scale(0.96);
    transition: transform 0.2s ease;
}

.modal-backdrop.open .modal-content {
    transform: scale(1);
}

/* AI Status Badges */
.badge-ai {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.2rem 0.55rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-ai-analyzed   { background: rgba(16, 185, 129, 0.15); color: #10b981; border: 1px solid rgba(16, 185, 129, 0.3); }
.badge-ai-processing { background: rgba(245, 158, 11, 0.15); color: #f59e0b; border: 1px solid rgba(245, 158, 11, 0.3); }
.badge-ai-queued     { background: rgba(14, 165, 233, 0.15); color: #0ea5e9; border: 1px solid rgba(14, 165, 233, 0.3); }
.badge-ai-failed     { background: rgba(244, 63, 94, 0.15);  color: #f43f5e; border: 1px solid rgba(244, 63, 94, 0.3); }
.badge-ai-not        { background: rgba(100, 116, 139, 0.15); color: #94a3b8; border: 1px solid rgba(100, 116, 139, 0.3); }

/* File Selection */
.file-item-selectable.selected {
    border-color: #6366f1 !important;
    background: rgba(99, 102, 241, 0.1) !important;
}

/* AI Co-Pilot Action Card */
.ai-action-card {
    border-left: 3px solid #3b82f6;
    background: rgba(59, 130, 246, 0.08);
    border-radius: 0.75rem;
    padding: 0.75rem 1rem;
    margin-top: 0.5rem;
    font-size: 0.8125rem;
}

/* Universal Auth Input Dark Styling - Guarantees Crisp White Text on Dark Background */
.auth-input,
.auth-card input[type="text"],
.auth-card input[type="email"],
.auth-card input[type="password"] {
    background-color: #0A0F1D !important;
    color: #FFFFFF !important;
    -webkit-text-fill-color: #FFFFFF !important;
    caret-color: #38BDF8 !important;
    border: 1px solid rgba(255, 255, 255, 0.16) !important;
}

.auth-input:focus,
.auth-card input:focus {
    background-color: #0D1627 !important;
    color: #FFFFFF !important;
    -webkit-text-fill-color: #FFFFFF !important;
    border-color: #3B82F6 !important;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25) !important;
}

.auth-input::placeholder,
.auth-card input::placeholder {
    color: #64748B !important;
    -webkit-text-fill-color: #64748B !important;
}

/* Fix browser autofill from making inputs white or yellow */
.auth-input:-webkit-autofill,
.auth-card input:-webkit-autofill {
    -webkit-box-shadow: 0 0 0 1000px #0A0F1D inset !important;
    -webkit-text-fill-color: #FFFFFF !important;
    caret-color: #FFFFFF !important;
    box-shadow: 0 0 0 1000px #0A0F1D inset !important;
}
