/* Dr Mizaj Dashboard — Design System */
:root {
    --font-sans: Tahoma, 'Segoe UI', Arial, sans-serif;
    --primary: #0d9488;
    --primary-dark: #0f766e;
    --primary-light: #5eead4;
    --accent: #6366f1;
    --accent-soft: rgba(99, 102, 241, 0.12);
    --bg: #f1f5f9;
    --surface: #ffffff;
    --sidebar-bg: #0f172a;
    --sidebar-hover: rgba(255, 255, 255, 0.06);
    --sidebar-active: rgba(13, 148, 136, 0.25);
    --text: #0f172a;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
    --shadow-md: 0 4px 20px rgba(15, 23, 42, 0.08);
    --shadow-lg: 0 12px 40px rgba(15, 23, 42, 0.12);
    --radius: 12px;
    --radius-lg: 16px;
    --header-h: 64px;
    --sidebar-w: 260px;
    --transition: 0.2s ease;
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
    font-family: var(--font-sans);
    color: var(--text);
    background: var(--bg);
    min-height: 100%;
}

/* Bootstrap overrides */
.btn-primary {
    --bs-btn-bg: var(--primary);
    --bs-btn-border-color: var(--primary);
    --bs-btn-hover-bg: var(--primary-dark);
    --bs-btn-hover-border-color: var(--primary-dark);
    --bs-btn-active-bg: var(--primary-dark);
    --bs-btn-active-border-color: var(--primary-dark);
}

.text-primary { color: var(--primary) !important; }
.bg-primary { background-color: var(--primary) !important; }

.form-control:focus,
.form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 0.2rem rgba(13, 148, 136, 0.2);
}

/* App shell */
.app-shell {
    display: flex;
    min-height: 100vh;
}

.app-sidebar {
    width: var(--sidebar-w);
    background: var(--sidebar-bg);
    color: #e2e8f0;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 1040;
    transition: transform var(--transition);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1.25rem 1.25rem 1rem;
    text-decoration: none;
    color: #fff;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-brand img {
    width: 40px;
    height: 40px;
    border-radius: 10px;
}

.sidebar-brand span {
    font-weight: 700;
    font-size: 1.05rem;
    line-height: 1.3;
}

.sidebar-brand small {
    display: block;
    font-size: 0.7rem;
    font-weight: 400;
    color: #94a3b8;
    margin-top: 2px;
}

.sidebar-nav {
    flex: 1;
    padding: 1rem 0.75rem;
    overflow-y: auto;
}

.sidebar-nav .nav-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #64748b;
    padding: 0.5rem 0.75rem 0.35rem;
    margin-top: 0.5rem;
}

.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.65rem 0.85rem;
    color: #cbd5e1;
    text-decoration: none;
    border-radius: 10px;
    margin-bottom: 2px;
    font-size: 0.9rem;
    transition: background var(--transition), color var(--transition);
}

.sidebar-nav .nav-link i {
    font-size: 1.15rem;
    opacity: 0.85;
}

.sidebar-nav .nav-link:hover {
    background: var(--sidebar-hover);
    color: #fff;
}

.sidebar-nav .nav-link.active {
    background: var(--sidebar-active);
    color: #5eead4;
    font-weight: 600;
}

.sidebar-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    font-size: 0.8rem;
    color: #64748b;
}

.app-main {
    flex: 1;
    margin-right: var(--sidebar-w);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.app-topbar {
    height: var(--header-h);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    position: sticky;
    top: 0;
    z-index: 1030;
    box-shadow: var(--shadow-sm);
}

.topbar-title h1 {
    font-size: 1.15rem;
    font-weight: 700;
    margin: 0;
    color: var(--text);
}

.topbar-title .breadcrumb-text {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin: 0;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.user-pill {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0.75rem;
    background: var(--bg);
    border-radius: 999px;
    font-size: 0.85rem;
}

.user-pill i {
    font-size: 1.25rem;
    color: var(--primary);
}

.app-content {
    flex: 1;
    padding: 1.5rem;
}

.app-footer {
    padding: 1rem 1.5rem;
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-muted);
    border-top: 1px solid var(--border);
    background: var(--surface);
}

.sidebar-toggle {
    display: none;
    border: none;
    background: var(--bg);
    border-radius: 8px;
    padding: 0.4rem 0.6rem;
    color: var(--text);
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    z-index: 1035;
}

/* Cards & panels */
.card-app {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.card-app .card-header {
    background: transparent;
    border-bottom: 1px solid var(--border);
    padding: 1rem 1.25rem;
    font-weight: 600;
}

.card-app .card-body {
    padding: 1.25rem;
}

.page-hero {
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 50%, #2dd4bf 100%);
    color: #fff;
    border-radius: var(--radius-lg);
    padding: 1.5rem 1.75rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-md);
}

.page-hero h2 {
    font-weight: 700;
    margin-bottom: 0.35rem;
}

.page-hero p {
    opacity: 0.9;
    margin: 0;
    font-size: 0.95rem;
}

.page-hero .stat-chip {
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(8px);
    border-radius: var(--radius);
    padding: 0.65rem 1rem;
    text-align: center;
    min-width: 90px;
}

.page-hero .stat-chip strong {
    display: block;
    font-size: 1.35rem;
    line-height: 1.2;
}

.page-hero .stat-chip span {
    font-size: 0.75rem;
    opacity: 0.85;
}

/* KPI stats */
.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.15rem 1.25rem;
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    transition: box-shadow var(--transition), transform var(--transition);
    height: 100%;
}

.stat-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.stat-card .stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.35rem;
    flex-shrink: 0;
}

.stat-card .stat-icon.teal { background: rgba(13, 148, 136, 0.12); color: var(--primary); }
.stat-card .stat-icon.indigo { background: var(--accent-soft); color: var(--accent); }
.stat-card .stat-icon.amber { background: rgba(245, 158, 11, 0.12); color: #d97706; }
.stat-card .stat-icon.rose { background: rgba(244, 63, 94, 0.12); color: #e11d48; }

.stat-card .stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.2;
    color: var(--text);
}

.stat-card .stat-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.stat-card .stat-trend {
    font-size: 0.75rem;
    margin-top: 0.35rem;
}

.stat-card .stat-trend.up { color: #059669; }
.stat-card .stat-trend.down { color: #dc2626; }

/* Chart containers */
.chart-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    height: 100%;
}

.chart-panel .chart-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
}

/* Select people page */
.panel-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    height: 100%;
}

.panel-card .panel-head {
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 1rem;
}

.chart-section .panel-head-compact {
    padding-bottom: 0.5rem;
    margin-bottom: 0.5rem;
}

.chart-section .panel-head-compact h5 {
    font-size: 1rem;
}

.chart-section .panel-head-compact small {
    font-size: 0.78rem;
}

.chart-canvas-wrap {
    position: relative;
    height: 220px;
    width: 100%;
}

.chart-canvas-wrap canvas {
    display: block;
    width: 100% !important;
    height: 100% !important;
}

.user-list-scroll {
    max-height: 500px;
    overflow: auto;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.user-row {
    cursor: pointer;
    transition: background var(--transition);
    padding: 0.75rem 1rem !important;
}

.user-row:hover {
    background: rgba(13, 148, 136, 0.04);
}

.user-row:last-child {
    border-bottom: none !important;
}

#propsList {
    max-height: 420px;
    overflow: auto;
    padding-left: 4px;
}

#propsList .prop-item {
    padding: 0.5rem 0.65rem;
    border-radius: 8px;
    transition: background var(--transition);
}

#propsList .prop-item:hover {
    background: var(--bg);
}

.avatar-ring {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--border);
    background: var(--bg);
}

.search-bar {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.search-bar .form-control {
    flex: 1;
    min-width: 140px;
}

.chart-export-actions .btn:disabled {
    opacity: 0.45;
}

@media print {
    body * {
        visibility: hidden;
    }

    #chartExportArea,
    #chartExportArea * {
        visibility: visible;
    }

    #chartExportArea {
        position: absolute;
        right: 0;
        top: 0;
        width: 100%;
    }

    .chart-export-actions,
    .app-sidebar,
    .app-topbar,
    .app-footer {
        display: none !important;
    }
}

/* Auth pages */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
    background: linear-gradient(145deg, #0f172a 0%, #134e4a 45%, #0d9488 100%);
    position: relative;
    overflow: hidden;
}

.auth-page::before {
    content: '';
    position: absolute;
    width: 600px;
    height: 600px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(94, 234, 212, 0.15) 0%, transparent 70%);
    top: -200px;
    left: -150px;
    pointer-events: none;
}

.auth-page::after {
    content: '';
    position: absolute;
    width: 400px;
    height: 400px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(99, 102, 241, 0.12) 0%, transparent 70%);
    bottom: -100px;
    right: -80px;
    pointer-events: none;
}

.auth-card {
    width: 100%;
    max-width: 420px;
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 2rem;
    position: relative;
    z-index: 1;
}

.auth-brand {
    text-align: center;
    margin-bottom: 1.75rem;
}

.auth-brand img {
    width: 56px;
    height: 56px;
    margin-bottom: 0.75rem;
}

.auth-brand h1 {
    font-size: 1.35rem;
    font-weight: 700;
    margin: 0;
    color: var(--text);
}

.auth-brand p {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin: 0.35rem 0 0;
}

.auth-card .form-label {
    font-weight: 500;
    font-size: 0.9rem;
}

.input-group-icon {
    position: relative;
}

.input-group-icon i {
    position: absolute;
    top: 50%;
    right: 12px;
    transform: translateY(-50%);
    color: var(--text-muted);
    z-index: 5;
}

.input-group-icon .form-control {
    padding-right: 2.5rem;
}

/* Quick actions sidebar on home */
.quick-action-btn {
    text-align: right;
    padding: 0.65rem 1rem;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.65rem;
    transition: all var(--transition);
    font-size: 0.9rem;
}

.quick-action-btn:hover {
    border-color: var(--primary);
    background: rgba(13, 148, 136, 0.06);
    color: var(--primary-dark);
}

.quick-action-btn i {
    font-size: 1.1rem;
    color: var(--primary);
}

/* Responsive */
@media (max-width: 991.98px) {
    .app-sidebar {
        transform: translateX(100%);
    }

    .app-sidebar.open {
        transform: translateX(0);
    }

    .sidebar-overlay.show {
        display: block;
    }

    .app-main {
        margin-right: 0;
    }

    .sidebar-toggle {
        display: inline-flex;
        align-items: center;
    }
}

@media (max-width: 575.98px) {
    .app-content {
        padding: 1rem;
    }

    .page-hero {
        padding: 1.25rem;
    }

    .search-bar {
        flex-direction: column;
    }

    .search-bar .btn {
        width: 100%;
    }
}
