/* Reset & typography */
* { box-sizing: border-box; }

html, body {
    padding: 0;
    margin: 0;
    min-height: 100vh;
}

body {
    font-family: var(--font-body);
    background: var(--bg-app);
    color: var(--text-primary);
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    margin: 0;
    color: var(--text-primary);
}

p { margin: 0; }
a { color: inherit; text-decoration: none; }

img { max-width: 100%; display: block; }

::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--bg-app); }
::-webkit-scrollbar-thumb { background: var(--primary); border-radius: 4px; }

/* Utilities */
.text-primary { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-muted { color: var(--text-muted); }
.text-on-accent { color: var(--text-on-accent); }

.bg-surface-1 { background: var(--bg-surface-1); }
.bg-surface-2 { background: var(--bg-surface-2); }
.border-default { border: var(--border-width) solid var(--border-color); }

.shadow-soft { box-shadow: var(--shadow-soft); }

.grid-responsive { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }

/* Simple utilities (fallback when utility libs aren't present) */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }
.mb-8 { margin-bottom: 2rem; }
.mb-6 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 1rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-8 { margin-top: 2rem; }
.mx-auto { margin-left: auto; margin-right: auto; }
.w-full { width: 100%; }

.stack-md > * + * { margin-top: 1.5rem; }
.stack-sm > * + * { margin-top: 1rem; }

.flex { display: flex; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.flex-col { flex-direction: column; }
.uppercase { text-transform: uppercase; }
.tracking-wider { letter-spacing: 0.05em; }
.grid { display: grid; }
.grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.gap-3 { gap: 0.75rem; }
.gap-2 { gap: 0.5rem; }

/* Typography fallbacks (in case Tailwind CDN is unavailable or overridden) */
.text-xs { font-size: 0.75rem; line-height: 1rem; }
.text-sm { font-size: 0.875rem; line-height: 1.25rem; }
.text-10px { font-size: 10px; line-height: 14px; }
.text-green-400 { color: var(--green-400); }
.text-purple-400 { color: var(--purple-400); }
.text-blue-400 { color: var(--blue-400); }
.text-gray-400 { color: var(--gray-400); }
.bg-gray-800 { background-color: var(--gray-800); }

/* Ensure our palette wins over Tailwind defaults in light mode */
:root[data-theme="light"] .text-green-400 { color: var(--green-400) !important; }
:root[data-theme="light"] .text-purple-400 { color: var(--purple-400) !important; }
:root[data-theme="light"] .text-blue-400 { color: var(--blue-400) !important; }
:root[data-theme="light"] .text-gray-400 { color: var(--gray-400) !important; }
:root[data-theme="light"] .fw-copy { color: #4b5563 !important; } /* Tailwind gray-600 */
:root[data-theme="dark"]  .fw-copy { color: var(--gray-400) !important; }

/* Legacy compatibility layer for hardcoded gray classes (light theme only) */
:root[data-theme="light"] .bg-gray-900,
:root[data-theme="light"] .bg-gray-800,
:root[data-theme="light"] .bg-gray-700 {
    background-color: var(--bg-surface-1) !important;
}
:root[data-theme="light"] .bg-gray-800\/60,
:root[data-theme="light"] .bg-gray-800\/50,
:root[data-theme="light"] .bg-gray-800\/40,
:root[data-theme="light"] .bg-gray-800\/30,
:root[data-theme="light"] .bg-gray-700\/30,
:root[data-theme="light"] .bg-gray-600\/30 {
    background-color: var(--surface-subtle) !important;
}
:root[data-theme="light"] .border-gray-800,
:root[data-theme="light"] .border-gray-700,
:root[data-theme="light"] .divide-gray-800 {
    border-color: var(--table-divider) !important;
}
:root[data-theme="light"] [class*="hover:bg-gray-800"]:hover,
:root[data-theme="light"] [class*="hover:bg-gray-700"]:hover {
    background-color: var(--row-hover-soft) !important;
}

/* Login logos by theme */
.logo-login-dark-theme,
.logo-login-light-theme {
    display: none;
}
:root[data-theme="dark"] .logo-login-dark-theme {
    display: block;
}
:root[data-theme="dark"] .logo-login-light-theme {
    display: none;
}
:root[data-theme="light"] .logo-login-light-theme {
    display: block;
}
:root[data-theme="light"] .logo-login-dark-theme {
    display: none;
}

/* Sidebar logos by theme */
.logo-sidebar-dark-theme,
.logo-sidebar-light-theme {
    display: none;
}
:root[data-theme="dark"] .logo-sidebar-dark-theme {
    display: block;
}
:root[data-theme="dark"] .logo-sidebar-light-theme {
    display: none;
}
:root[data-theme="light"] .logo-sidebar-light-theme {
    display: block;
}
:root[data-theme="light"] .logo-sidebar-dark-theme {
    display: none;
}
