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

/* Color tokens + font stack */
:root {
    --slate-50: #f8fafc;
    --slate-100: #f1f5f9;
    --slate-200: #e2e8f0;
    --slate-300: #cbd5e1;
    --slate-400: #94a3b8;
    --slate-600: #64748b;
    --slate-700: #334155;
    --slate-900: #0f172a; /* This is the Dark/Black color */
    --indigo-50: #eef2ff;
    --indigo-600: #4f46e5;
    --white: #ffffff;
    --black: #000000;

    --app-font-sans: system-ui, -apple-system, BlinkMacSystemFont,
                     "SF Pro Text", "SF Pro Display", "Inter",
                     "Segoe UI", sans-serif;
}

/* Reset */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Base layout / typography */
html, body {
    height: 100%;
    width: 100%;
    font-family: var(--app-font-sans);
    font-size: 14px;
    color: var(--slate-700);
    background-color: var(--slate-100);
    scroll-behavior: smooth;
}

body {
    display: flex;
    flex-direction: column;
    line-height: 1.5;
}

/* Apple-inspired shell background */
.app-shell {
    background: radial-gradient(circle at top left, #f5f7fb 0%, #e5e9f5 40%, #dfe4f0 100%);
}

/* Headings */
h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    color: var(--slate-900);
    margin-bottom: 1rem;
}

p {
    line-height: 1.6;
}

/* Glass helper */
.glass-panel {
    background: rgba(255, 255, 255, 0.75);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-right: 1px solid rgba(255, 255, 255, 0.5);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.02);
}

/* Sidebar – Apple-like dark glass */
.sidebar {
    background: rgba(15, 23, 42, 0.94);
    backdrop-filter: blur(22px);
    -webkit-backdrop-filter: blur(22px);
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    width: 285px;
    z-index: 999;
    transition: all 0.3s ease;
    overflow-y: auto;
    border-right: 1px solid rgba(148, 163, 184, 0.35);
}

/* Sidebar nav container */
.sidebar .nav {
    padding: 0 16px 16px;
}

/* All sidebar links */
.sidebar .nav-link {
    color: #e5e7eb;
    padding: 8px 12px;
    border-radius: 12px;
    margin: 2px 0;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    text-decoration: none;
    font-size: 14px;
}

/* Icons in sidebar */
.sidebar .nav-link i.fa-fw {
    width: 20px;
    text-align: center;
    margin-right: 12px;
}

/* Unified hover/active – light grey pill */
.sidebar .nav-link:hover {
    background: rgba(148, 163, 184, 0.18);
    color: #f9fafb;
}

.sidebar .nav-link.active {
    background: rgba(148, 163, 184, 0.28);
    color: #f9fafb;
}

/* Submenu indentation and behavior */
.submenu .nav-link {
    padding-left: 28px;
    font-size: 13px;
    color: rgba(226, 232, 240, 0.9);
    background: transparent;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
}

/* Chevron rotation */
.sidebar .nav-link .menu-arrow {
    margin-left: auto;
    transition: transform 0.2s ease-in-out;
}

.sidebar .nav-link[aria-expanded="true"] .menu-arrow {
    transform: rotate(90deg);
}

/* Navbar – light floating bar */
.navbar {
    margin-left: 300px;
    position: fixed;
    top: 0;
    right: 0;
    left: 300px;
    z-index: 998;
    background: rgba(248, 250, 252, 0.92) !important;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(148, 163, 184, 0.25);
    height: 76px;
    display: flex;
    align-items: center;
    padding: 0 30px;
}

/* Main content */
.main-content {
    margin-left: 300px;
    margin-top: 76px;
    min-height: 100vh;
    background-color: var(--slate-100);
    flex: 1;
}

.content-wrapper {
    padding: 24px 24px 32px;
    max-width: 100%;
}

@media (min-width: 992px) {
    .main-content .content-wrapper {
        padding: 32px 40px 40px;
    }
}

/* Form controls */
input, textarea, select {
    background-color: var(--slate-50) !important;
    border: 1px solid var(--slate-200) !important;
    border-radius: 10px !important;
    padding: 10px 14px !important;
    font-family: var(--app-font-sans);
    color: var(--slate-700) !important;
}

input:focus, textarea:focus, select:focus {
    background-color: var(--white) !important;
    border-color: var(--slate-900) !important; /* Focus Black */
    box-shadow: 0 0 0 3px rgba(15, 23, 42, 0.1) !important;
    outline: none !important;
}

/* --- BUTTONS (UPDATED to BLACK) --- */
.btn {
    border-radius: 8px !important;
    font-weight: 500 !important;
    transition: all 0.2s ease;
}

/* CHANGED: Primary is now Slate-900 (Black/Dark Blue) */
.btn-primary {
    background-color: var(--slate-900) !important;
    background-image: none !important; /* No gradients */
    border: 1px solid var(--slate-900) !important;
    border-radius: 8px !important;
    color: white !important;
    font-weight: 500;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.2) !important;
    transition: all 0.2s ease;
}

.btn-primary:hover, .btn-primary:active, .btn-primary:focus {
    background-color: #000000 !important; /* Pure Black on Hover */
    border-color: #000000 !important;
    background-image: none !important;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3) !important;
    transform: translateY(-1px);
}

.btn-secondary {
    background-color: var(--slate-100) !important;
    border: 1px solid var(--slate-200) !important;
    color: var(--slate-900) !important;
}

.btn-secondary:hover {
    background-color: var(--slate-200) !important;
}

.btn-outline-secondary {
    background-color: transparent !important;
    border: 1px solid var(--slate-200) !important;
    color: var(--slate-700) !important;
}

.btn-outline-secondary:hover {
    background-color: var(--slate-50) !important;
    color: var(--slate-900) !important;
}

/* Cards */
.card {
    background-color: var(--white);
    border: none;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    transition: all 0.2s ease;
    margin-bottom: 20px;
}

.card:hover {
    box-shadow: 0 4px 5px rgba(0, 0, 0, 0.08);
}

.card-header {
    background-color: var(--white);
    border-bottom: 1px solid var(--slate-200);
    padding: 20px;
    border-radius: 12px 12px 0 0;
    font-weight: 600;
    color: var(--slate-900);
}

.card-body {
    padding: 20px;
    background-color: var(--white);
}

/* --- APPLE STYLE PERMISSION CARDS & TOGGLES (Global) --- */

/* 1. Base Card Style */
.permission-card {
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    border: 1px solid var(--slate-200);
    background-color: var(--white);
    cursor: pointer;
    position: relative;
    overflow: hidden;
    display: block;
    margin-bottom: 0;
    border-radius: 12px; 
}

.permission-card:hover {
    border-color: var(--slate-300);
    background-color: #fcfcfc;
    transform: translateY(-1px);
}

/* 2. ACTIVE STATE (Dark Grey / Monochrome) */
.permission-card:has(.form-check-input:checked) {
    background-color: var(--slate-50) !important;
    border-color: var(--slate-700) !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.permission-card:has(.form-check-input:checked) .fw-bold,
.permission-card:has(.form-check-input:checked) .fw-semibold {
    color: var(--slate-900); 
    font-weight: 700 !important;
}

/* 3. APPLE STYLE TOGGLE SWITCH */
.form-switch .form-check-input {
    width: 3.2em;
    height: 1.6em;
    cursor: pointer;
    margin-left: 0 !important;
    border-radius: 2em;
    background-color: var(--slate-200);
    border-color: var(--slate-300);
    transition: background-color 0.3s ease, border-color 0.3s ease, background-position 0.3s ease;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='%23fff'/%3e%3c/svg%3e");
}

/* Active Switch Color (Dark Grey/Black) */
.form-check-input:checked {
    background-color: var(--slate-900) !important; 
    border-color: var(--slate-900) !important;
    background-position: right center;
}

.form-check-input:focus {
    box-shadow: 0 0 0 0.25rem rgba(15, 23, 42, 0.15);
    border-color: var(--slate-900);
}

/* --- END GLOBAL APPLE STYLES --- */

/* Tables */
.table {
    background-color: var(--white);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    border: none;
}

.table thead th {
    background-color: var(--slate-50);
    border: none;
    border-bottom: 1px solid var(--slate-200);
    font-weight: 600;
    color: var(--slate-900);
    padding: 15px;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.table tbody td {
    padding: 15px;
    border-bottom: 1px solid var(--slate-200);
    vertical-align: middle;
    color: var(--slate-700);
}

.table tbody tr {
    transition: all 0.2s ease;
}

.table tbody tr:hover {
    background-color: var(--slate-50);
}

.table-responsive {
    border-radius: 12px;
    overflow: hidden;
}

/* Badges */
.badge {
    border-radius: 12px;
    padding: 4px 12px;
    font-size: 12px;
    font-weight: 600;
}

.badge.bg-danger { background-color: #ef4444 !important; }
.badge.bg-success { background-color: #10b981 !important; }
.badge.bg-secondary { background-color: var(--slate-400) !important; }

/* Dashboard Stat Cards */
.stats-card {
    position: relative;
    overflow: hidden;
    border-radius: 18px;
    background: #020617;
    border: 1px solid rgba(148, 163, 184, 0.45);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    box-shadow: 0 18px 30px rgba(15, 23, 42, 0.9), 0 0 0 1px rgba(15, 23, 42, 0.9);
    color: #e5e7eb;
}

.stats-card::before { content: ""; position: absolute; inset: 0; background: radial-gradient(circle at top, rgba(255, 255, 255, 0.04), transparent 60%); opacity: 1; pointer-events: none; }
.stats-card .card-body { position: relative; z-index: 1; }
.stats-value { font-size: 20px; font-weight: 600; letter-spacing: -0.02em; color: #000000; }
.stats-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.14em; color: #000000; margin-top: 4px; }
.stats-icon { width: 38px; height: 38px; border-radius: 999px; display: inline-flex; align-items: center; justify-content: center; color: #f9fafb; font-size: 17px; background: radial-gradient(circle at top left, rgba(15, 23, 42, 0.95), rgba(30, 64, 175, 0.95)); box-shadow: 0 0 0 1px rgba(148, 163, 184, 0.55), 0 10px 25px rgba(0, 0, 0, 0.9); }

/* Accent glows */
.stats-card-blue::after { content: ""; position: absolute; inset: 0; pointer-events: none; mix-blend-mode: screen; opacity: 0.55; background: radial-gradient(circle at top right, rgba(59, 130, 246, 0.9), transparent 65%); }
.stats-card-green::after { content: ""; position: absolute; inset: 0; pointer-events: none; mix-blend-mode: screen; opacity: 0.55; background: radial-gradient(circle at top right, rgba(16, 185, 129, 0.9), transparent 65%); }
.stats-card-orange::after { content: ""; position: absolute; inset: 0; pointer-events: none; mix-blend-mode: screen; opacity: 0.55; background: radial-gradient(circle at top right, rgba(249, 115, 22, 0.95), transparent 65%); }
.stats-card-red::after { content: ""; position: absolute; inset: 0; pointer-events: none; mix-blend-mode: screen; opacity: 0.55; background: radial-gradient(circle at top right, rgba(239, 68, 68, 0.95), transparent 65%); }

/* Responsive */
@media (max-width: 1024px) {
    .sidebar { transform: translateX(-100%); width: 260px; }
    .sidebar.show { transform: translateX(0); }
    .navbar { margin-left: 0; left: 0; height: 50px; padding: 0 15px; display: flex; align-items: center; justify-content: space-between; }
    .main-content { margin-left: 0; margin-top: 50px; margin-bottom: 60px; padding-bottom: 60px; }
    .content-wrapper { padding: 20px; }
    .navbar h1 { font-size: 18px; margin: 0; }
    .bottom-nav { position: fixed; bottom: 0; left: 0; right: 0; height: 60px; background: rgba(15, 23, 42, 0.96); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border-top: 1px solid rgba(148, 163, 184, 0.3); box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.25); display: flex; justify-content: space-around; align-items: center; z-index: 1000; gap: 8px; padding: 0 10px; }
    .bottom-nav .nav-item { display: flex; flex-direction: column; align-items: center; justify-content: center; flex: 1; cursor: pointer; text-decoration: none; color: var(--slate-300); font-size: 11px; transition: all 0.2s ease; padding: 5px; }
    .bottom-nav .nav-item:hover, .bottom-nav .nav-item.active { color: var(--indigo-50); }
    .bottom-nav .nav-item i { font-size: 20px; margin-bottom: 2px; }
    body { overflow-x: hidden; }
}

@media (max-width: 768px) {
    table, thead, tbody, th, td, tr { display: block; }
    thead tr { position: absolute; top: -9999px; left: -9999px; }
    tr { background: white; border-radius: 12px; margin-bottom: 16px; padding: 16px; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05); border: 1px solid var(--slate-200); display: block; width: 100%; }
    td { border: none; position: relative; padding-left: 50%; text-align: right; padding-bottom: 8px; padding-top: 12px; display: block; }
    td:before { content: attr(data-label); position: absolute; left: 0; width: 45%; padding-right: 10px; text-align: left; font-weight: 600; color: var(--slate-400); font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; }
    td:last-child { padding-bottom: 0; }
    .table-responsive { padding: 0 !important; }
    .card { margin-bottom: 16px; }
    .content-wrapper { padding: 16px; }
    h1 { font-size: 24px; }
    .btn { padding: 10px 16px !important; font-size: 14px !important; }
}

/* Visibility helpers */
.hidden-on-mobile { display: block; }
@media (max-width: 1024px) { .hidden-on-mobile { display: none; } }
.visible-on-mobile { display: none; }
@media (max-width: 1024px) { .visible-on-mobile { display: block; } }

/* Utility classes */
.d-flex { display: flex; }
.justify-content-between { justify-content: space-between; }
.align-items-center { align-items: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.mb-4 { margin-bottom: 24px; }
.mb-3 { margin-bottom: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-1 { margin-bottom: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 16px; }
.p-3 { padding: 16px; }
.p-5 { padding: 32px; }
.text-center { text-align: center; }
.text-muted { color: var(--slate-400); }
.text-primary { color: var(--indigo-600); }
.text-dark { color: var(--slate-900); }
.text-end { text-align: right; }
.text-success { color: #10b981; }
.text-danger { color: #ef4444; }
.text-warning { color: #f59e0b; }
.text-white { color: white !important; }
.text-decoration-none { text-decoration: none; }
.fw-semibold { font-weight: 600; }
.fw-bold { font-weight: 700; }
.small { font-size: 12px; }
.me-3 { margin-right: 12px; }
.me-1 { margin-right: 4px; }
.ms-auto { margin-left: auto; }
.opacity-50 { opacity: 0.5; }
.fa-4x { font-size: 3.5rem; }

/* Grid helpers */
.row { display: flex; flex-wrap: wrap; gap: 20px; }
.col-md-6 { flex: 1; min-width: 250px; }
.col-md-8 { flex: 1; min-width: 300px; }
.col-md-4 { flex: 1; min-width: 200px; }
@media (max-width: 768px) { .col-md-6, .col-md-8, .col-md-4 { flex: 1 1 100%; min-width: 100%; } .row { gap: 12px; } }

/* Avatars */
.avatar-sm { width: 40px; height: 40px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 14px; background-color: var(--slate-200); color: white; flex-shrink: 0; }
@media (min-width: 992px) { .dashboard-stat-col { flex: 0 0 22%; max-width: 22%; } }