/* =========================================================
   DentCare Pro — App Design System
   Light/Dark theme via [data-theme] on <html>
   ========================================================= */

:root {
    --font-sans: 'Inter', -apple-system, 'Segoe UI', Roboto, sans-serif;

    --primary: #6366f1;
    --primary-2: #8b5cf6;
    --primary-grad: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #0ea5e9;

    --bg: #f4f6fb;
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --text: #0f172a;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --shadow: 0 1px 3px rgba(15, 23, 42, .06), 0 8px 24px rgba(15, 23, 42, .05);
    --shadow-lg: 0 12px 40px rgba(15, 23, 42, .12);

    --sidebar-w: 260px;
    --topbar-h: 64px;
    --radius: 14px;
}

[data-theme="dark"] {
    --bg: #0b1120;
    --surface: #101a30;
    --surface-2: #16213b;
    --text: #e2e8f0;
    --text-muted: #94a3b8;
    --border: #24314e;
    --shadow: 0 1px 3px rgba(0, 0, 0, .35), 0 8px 24px rgba(0, 0, 0, .25);
    --shadow-lg: 0 12px 40px rgba(0, 0, 0, .5);
}

html { font-size: 15px; }

body {
    font-family: var(--font-sans);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    transition: background .25s ease, color .25s ease;
}

/* ---------- Sidebar ---------- */
.app-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-w);
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 1040;
    transition: transform .25s ease;
}

.sidebar-brand {
    height: var(--topbar-h);
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: 0 1.25rem;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.sidebar-brand .brand-icon {
    width: 38px;
    height: 38px;
    border-radius: 11px;
    background: var(--primary-grad);
    display: grid;
    place-items: center;
    color: #fff;
    font-size: 1.15rem;
    box-shadow: 0 4px 14px rgba(99, 102, 241, .4);
}

.sidebar-brand .brand-name {
    font-weight: 700;
    font-size: 1.05rem;
    letter-spacing: -.02em;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 1rem .75rem;
}

.sidebar-nav .nav-label {
    font-size: .68rem;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--text-muted);
    padding: 1rem .75rem .35rem;
    font-weight: 600;
}

.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    gap: .7rem;
    padding: .58rem .75rem;
    margin-bottom: 2px;
    border-radius: 10px;
    color: var(--text-muted);
    font-weight: 500;
    font-size: .92rem;
    transition: background .15s, color .15s;
}

.sidebar-nav .nav-link i {
    width: 20px;
    text-align: center;
    font-size: .95rem;
}

.sidebar-nav .nav-link:hover {
    background: var(--surface-2);
    color: var(--text);
}

.sidebar-nav .nav-link.active {
    background: var(--primary-grad);
    color: #fff;
    box-shadow: 0 4px 14px rgba(99, 102, 241, .35);
}

/* ---------- Topbar ---------- */
.app-topbar {
    position: fixed;
    top: 0;
    left: var(--sidebar-w);
    right: 0;
    height: var(--topbar-h);
    background: color-mix(in srgb, var(--surface) 85%, transparent);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0 1.5rem;
    z-index: 1030;
    transition: left .25s ease;
}

.topbar-search {
    max-width: 380px;
    flex: 1;
}

.topbar-search .form-control {
    background: var(--surface-2);
    border-color: transparent;
    border-radius: 10px;
    padding-left: 2.4rem;
}

.icon-btn {
    width: 40px;
    height: 40px;
    border-radius: 11px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-muted);
    display: grid;
    place-items: center;
    transition: all .15s;
}

.icon-btn:hover { color: var(--primary); border-color: var(--primary); }

/* ---------- Main content ---------- */
.app-main {
    margin-left: var(--sidebar-w);
    padding: calc(var(--topbar-h) + 1.5rem) 1.5rem 2rem;
    transition: margin .25s ease;
}

/* ---------- Cards ---------- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    color: var(--text);
}

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    padding: 1rem 1.25rem;
}

.stat-card { overflow: hidden; position: relative; }

.stat-card .stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 13px;
    display: grid;
    place-items: center;
    font-size: 1.25rem;
    color: #fff;
}

.stat-card .stat-value {
    font-size: 1.65rem;
    font-weight: 700;
    letter-spacing: -.03em;
}

.stat-card .stat-label {
    color: var(--text-muted);
    font-size: .85rem;
    font-weight: 500;
}

/* ---------- Buttons ---------- */
.btn-primary {
    background: var(--primary-grad);
    border: none;
    border-radius: 10px;
    font-weight: 600;
    padding: .55rem 1.2rem;
    box-shadow: 0 4px 14px rgba(99, 102, 241, .35);
}

.btn-primary:hover { filter: brightness(1.08); }

/* ---------- Forms ---------- */
.form-control {
    background: var(--surface);
    border-color: var(--border);
    color: var(--text);
    border-radius: 10px;
    padding: .55rem .9rem;
}

.form-select {
    /* background-color only (not the `background` shorthand) — the
       shorthand resets background-image to none, which was silently
       wiping out Bootstrap's built-in dropdown caret SVG on every select. */
    background-color: var(--surface);
    border-color: var(--border);
    color: var(--text);
    border-radius: 10px;
    padding: .55rem .9rem;
}

[data-theme="dark"] .form-select {
    /* Bootstrap's caret SVG is baked with a fixed dark-gray stroke at
       build time (CDN bundle, not recompiled) — swap in a light-colored
       caret so it's actually visible against dark-theme surfaces. */
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%2394a3b8' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e");
}

.form-control:focus {
    background: var(--surface);
    color: var(--text);
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, .15);
}

.form-select:focus {
    background-color: var(--surface);
    color: var(--text);
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, .15);
}

.form-label { font-weight: 600; font-size: .85rem; margin-bottom: .35rem; }

/* ---------- Tables ---------- */
.table { color: var(--text); border-color: var(--border); }
.table thead th {
    font-size: .75rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--text-muted);
    border-bottom-width: 1px;
    background: var(--surface-2);
}
.table > :not(caption) > * > * { background: transparent; color: inherit; }
.table-hover tbody tr:hover td { background: var(--surface-2); }

/* ---------- Auth pages ---------- */
.auth-wrapper {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 1.5rem;
    background:
        radial-gradient(60% 60% at 15% 10%, rgba(99, 102, 241, .18) 0%, transparent 60%),
        radial-gradient(50% 50% at 90% 85%, rgba(139, 92, 246, .16) 0%, transparent 60%),
        var(--bg);
}

.auth-card {
    width: 100%;
    max-width: 420px;
    border-radius: 20px;
    box-shadow: var(--shadow-lg);
}

/* ---------- Skeletons ---------- */
.skeleton {
    background: linear-gradient(90deg, var(--surface-2) 25%, var(--border) 50%, var(--surface-2) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.4s infinite;
    border-radius: 8px;
}

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

/* ---------- Misc ---------- */
.text-muted { color: var(--text-muted) !important; }
.dropdown-menu {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
}
.dropdown-item { color: var(--text); border-radius: 8px; }
.dropdown-item:hover { background: var(--surface-2); color: var(--text); }

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- Responsive ---------- */
@media (max-width: 991.98px) {
    .app-sidebar { transform: translateX(-100%); }
    .app-sidebar.show { transform: translateX(0); box-shadow: var(--shadow-lg); }
    .app-topbar { left: 0; }
    .app-main { margin-left: 0; }

    .sidebar-backdrop {
        position: fixed;
        inset: 0;
        background: rgba(15, 23, 42, .5);
        z-index: 1039;
    }
}
