/* ===== Variables ===== */
:root {
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 0px;
    --topbar-height: 60px;
    --sidebar-bg: #1e293b;
    --sidebar-hover: #334155;
    --sidebar-active: #0ea5e9;
    --sidebar-text: #94a3b8;
    --sidebar-text-active: #ffffff;
    --sidebar-brand-bg: #0f172a;
    --topbar-bg: #ffffff;
    --body-bg: #f1f5f9;
    --text-dark: #1e293b;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.15);
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --transition-speed: 0.3s;
}

/* ===== Reset & Base ===== */
*, *::before, *::after {
    box-sizing: border-box;
}

html {
    font-size: 14px;
}

@media (min-width: 768px) {
    html { font-size: 15px; }
}

body {
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background-color: var(--body-bg);
    color: var(--text-dark);
    min-height: 100vh;
    overflow-x: hidden;
}

a { text-decoration: none; }

/* ===== Sidebar Overlay ===== */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 1040;
    backdrop-filter: blur(2px);
    transition: opacity var(--transition-speed) ease;
}

.sidebar-overlay.active {
    display: block;
}

/* ===== Sidebar ===== */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg);
    z-index: 1050;
    display: flex;
    flex-direction: column;
    transition: transform var(--transition-speed) cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
    overflow-x: hidden;
    box-shadow: var(--shadow-lg);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 20px;
    height: var(--topbar-height);
    background: var(--sidebar-brand-bg);
    border-bottom: 1px solid rgba(255,255,255,0.06);
    flex-shrink: 0;
}

.brand-icon {
    font-size: 1.4rem;
    color: var(--sidebar-active);
}

.brand-text {
    font-size: 1.15rem;
    font-weight: 700;
    color: #fff;
    letter-spacing: 0.3px;
}

/* ===== Sidebar Nav ===== */
.sidebar-nav {
    display: flex;
    flex-direction: column;
    padding: 16px 12px;
    gap: 4px;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 11px 16px;
    border-radius: var(--radius-sm);
    color: var(--sidebar-text);
    font-size: 0.92rem;
    font-weight: 500;
    transition: all 0.2s ease;
    position: relative;
}

.sidebar-link i {
    font-size: 1.05rem;
    width: 22px;
    text-align: center;
    flex-shrink: 0;
    transition: color 0.2s ease;
}

.sidebar-link:hover {
    background: var(--sidebar-hover);
    color: var(--sidebar-text-active);
    transform: translateX(3px);
}

.sidebar-link:hover i {
    color: var(--sidebar-active);
}

.sidebar-link.active {
    background: var(--sidebar-active);
    color: var(--sidebar-text-active);
    box-shadow: 0 2px 8px rgba(14, 165, 233, 0.35);
}

.sidebar-link.active i {
    color: var(--sidebar-text-active);
}

.sidebar-link.active::before {
    content: '';
    position: absolute;
    left: -12px;
    top: 50%;
    transform: translateY(-50%);
    width: 4px;
    height: 60%;
    background: #fff;
    border-radius: 0 4px 4px 0;
}

/* ===== Main Wrapper ===== */
.main-wrapper {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-left var(--transition-speed) cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===== Topbar ===== */
.topbar {
    position: sticky;
    top: 0;
    z-index: 1030;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--topbar-height);
    padding: 0 24px;
    background: var(--topbar-bg);
    border-bottom: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.topbar-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-dark);
}

.hamburger-btn {
    display: none;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--body-bg);
    color: var(--text-dark);
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.hamburger-btn:hover {
    background: var(--border-color);
    transform: scale(1.05);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.topbar-link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    transition: all 0.2s ease;
}

.topbar-link:hover {
    background: var(--body-bg);
    color: var(--sidebar-active);
}

/* ===== Main Content ===== */
.main-content {
    flex: 1;
    padding: 28px 0;
}

/* ===== Footer ===== */
.dashboard-footer {
    padding: 16px 24px;
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-muted);
    border-top: 1px solid var(--border-color);
    background: var(--topbar-bg);
}

/* ===== Cards (dashboard feel) ===== */
.card, .table {
    border: none;
    box-shadow: var(--shadow-sm);
    border-radius: var(--radius-md);
}

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

.card:hover {
    box-shadow: var(--shadow-md);
}

.table {
    overflow: hidden;
}

.table thead th {
    background: #f8fafc;
    border-bottom: 2px solid var(--border-color);
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    padding: 12px 16px;
}

.table tbody td {
    padding: 12px 16px;
    vertical-align: middle;
}

/* ===== Buttons ===== */
.btn {
    border-radius: var(--radius-sm);
    font-weight: 500;
    transition: all 0.2s ease;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.btn:active {
    transform: translateY(0);
}

.btn-primary {
    background: var(--sidebar-active);
    border-color: var(--sidebar-active);
}

.btn-primary:hover {
    background: #0284c7;
    border-color: #0284c7;
}

.btn-success {
    background: #10b981;
    border-color: #10b981;
}

.btn-success:hover {
    background: #059669;
    border-color: #059669;
}

.btn-danger {
    background: #ef4444;
    border-color: #ef4444;
}

.btn-danger:hover {
    background: #dc2626;
    border-color: #dc2626;
}

.btn-warning {
    background: #f59e0b;
    border-color: #f59e0b;
    color: #fff;
}

.btn-warning:hover {
    background: #d97706;
    border-color: #d97706;
    color: #fff;
}

/* ===== Badges ===== */
.badge {
    font-weight: 500;
    padding: 5px 10px;
    border-radius: 20px;
    font-size: 0.78rem;
}

/* ===== Form Inputs ===== */
.form-control, .form-select {
    border-radius: var(--radius-sm);
    border-color: var(--border-color);
    padding: 10px 14px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-control:focus, .form-select:focus {
    border-color: var(--sidebar-active);
    box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.15);
}

/* ===== Mobile Responsive ===== */
@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
    }

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

    .main-wrapper {
        margin-left: 0;
    }

    .hamburger-btn {
        display: flex;
    }

    .topbar {
        padding: 0 16px;
    }
}

@media (min-width: 992px) {
    .sidebar-overlay {
        display: none !important;
    }
}

/* ===== Scrollbar Styling ===== */
.sidebar::-webkit-scrollbar {
    width: 5px;
}

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

.sidebar::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.15);
    border-radius: 10px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: rgba(255,255,255,0.25);
}

/* ===== Animations ===== */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.main-content .container-fluid {
    animation: fadeIn 0.35s ease;
}

/* ===== Focus Accessibility ===== */
.sidebar-link:focus-visible,
.hamburger-btn:focus-visible,
.topbar-link:focus-visible {
    outline: 2px solid var(--sidebar-active);
    outline-offset: 2px;
}

/* ===== Dashboard Cards ===== */
.dash-card {
    display: flex;
    align-items: center;
    gap: 18px;
    padding: 22px 24px;
    border-radius: var(--radius-md);
    background: #fff;
    box-shadow: var(--shadow-sm);
    transition: all 0.25s ease;
    border-left: 4px solid transparent;
}

.dash-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.dash-card-primary { border-left-color: var(--sidebar-active); }
.dash-card-warning { border-left-color: #f59e0b; }
.dash-card-success { border-left-color: #10b981; }
.dash-card-danger  { border-left-color: #ef4444; }

.dash-card-icon {
    width: 52px;
    height: 52px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    flex-shrink: 0;
}

.dash-card-primary .dash-card-icon { background: rgba(14,165,233,0.1); color: var(--sidebar-active); }
.dash-card-warning .dash-card-icon { background: rgba(245,158,11,0.1); color: #f59e0b; }
.dash-card-success .dash-card-icon { background: rgba(16,185,129,0.1); color: #10b981; }
.dash-card-danger  .dash-card-icon { background: rgba(239,68,68,0.1);  color: #ef4444; }

.dash-card-body {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.dash-card-label {
    font-size: 0.8rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--text-muted);
}

.dash-card-value {
    font-size: 1.65rem;
    font-weight: 700;
    color: var(--text-dark);
    line-height: 1.2;
}

.dash-card-sub {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 2px;
}

/* ===== Dashboard Mini Cards ===== */
.dash-card-mini {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 18px 20px;
    border-radius: var(--radius-md);
    background: #fff;
    box-shadow: var(--shadow-sm);
    transition: all 0.25s ease;
}

.dash-card-mini:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.dash-card-mini > i {
    width: 42px;
    height: 42px;
    border-radius: var(--radius-sm);
    background: rgba(14,165,233,0.08);
    color: var(--sidebar-active);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.05rem;
    flex-shrink: 0;
}

.dash-mini-value {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text-dark);
    display: block;
    line-height: 1.2;
}

.dash-mini-label {
    font-size: 0.78rem;
    color: var(--text-muted);
    display: block;
}

/* ===== Dashboard Table ===== */
.dash-card .table th {
    font-size: 0.78rem;
}

.dash-card .table td {
    font-size: 0.88rem;
}

/* ===== Overdue List ===== */
.list-group-item {
    border-color: var(--border-color);
}

.bg-danger-subtle {
    background: rgba(239,68,68,0.1) !important;
}

/* ===== Responsive ===== */
@media (max-width: 767.98px) {
    .dash-card {
        padding: 16px 18px;
    }
    .dash-card-icon {
        width: 44px;
        height: 44px;
        font-size: 1.1rem;
    }
    .dash-card-value {
        font-size: 1.35rem;
    }
}
