/* =====================================================
   SISTEM ABSENSI - Custom Styles
   ===================================================== */

:root {
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 70px;
    --topbar-height: 60px;
    --primary: #4361ee;
    --secondary: #3f37c9;
    --success: #4cc9f0;
    --accent: #f72585;
    --sidebar-bg: #1a1f2e;
    --sidebar-text: #a8b4cc;
    --sidebar-active: #4361ee;
    --card-shadow: 0 2px 20px rgba(0,0,0,.08);
    --transition: all .25s ease;
}

[data-bs-theme="dark"] {
    --sidebar-bg: #0f1117;
    --card-shadow: 0 2px 20px rgba(0,0,0,.3);
}

/* ===================== Base ===================== */
body { background: var(--bs-body-bg); font-family: 'Segoe UI', system-ui, sans-serif; }
.smaller { font-size: 0.75rem; }

/* ===================== Sidebar ===================== */
#wrapper {
    min-height: 100vh;
    display: flex;
}

.sidebar-wrapper {
    width: var(--sidebar-width);
    min-height: 100vh;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    flex-shrink: 0;
    transition: var(--transition);
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,.1) transparent;
    position: relative;
    z-index: 100;
}

.sidebar-wrapper::-webkit-scrollbar { width: 4px; }
.sidebar-wrapper::-webkit-scrollbar-thumb { background: rgba(255,255,255,.1); border-radius: 4px; }

.sidebar-heading {
    color: #fff;
    border-bottom: 1px solid rgba(255,255,255,.08);
    min-height: var(--topbar-height);
}

.sidebar-user {
    border-bottom: 1px solid rgba(255,255,255,.08);
}

.sidebar-user .avatar-sm { width: 38px; height: 38px; object-fit: cover; }

.sidebar-menu li a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    border-radius: 10px;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: .875rem;
    transition: var(--transition);
    margin-bottom: 2px;
}

.sidebar-menu li a:hover {
    background: rgba(255,255,255,.07);
    color: #fff;
}

.sidebar-menu li a.active {
    background: var(--primary);
    color: #fff;
    font-weight: 600;
}

.sidebar-menu li a i { font-size: 1.1rem; flex-shrink: 0; }
.menu-header { font-size: .7rem; letter-spacing: .08em; text-transform: uppercase; margin-bottom: 4px; }
.sidebar-divider { border-color: rgba(255,255,255,.08); }

/* Sidebar collapsed - desktop */
.sidebar-wrapper.collapsed { width: var(--sidebar-collapsed-width); }
.sidebar-wrapper.collapsed .sidebar-heading span,
.sidebar-wrapper.collapsed .sidebar-user div,
.sidebar-wrapper.collapsed .sidebar-menu li a span,
.sidebar-wrapper.collapsed .menu-header,
.sidebar-wrapper.collapsed .badge { display: none; }
.sidebar-wrapper.collapsed .sidebar-menu li a { justify-content: center; padding: 12px; }
.sidebar-wrapper.collapsed .sidebar-user { display: none; }

/* ===================== Main Content ===================== */
#page-content-wrapper {
    flex: 1;
    min-width: 0;
    min-height: 100vh;
    transition: var(--transition);
}

/* ===================== Topbar ===================== */
.topbar {
    background: var(--bs-body-bg);
    min-height: var(--topbar-height);
    position: sticky;
    top: 0;
    z-index: 99;
    box-shadow: 0 1px 10px rgba(0,0,0,.08);
}

.btn-icon {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--bs-border-color);
    background: var(--bs-body-bg);
    color: var(--bs-body-color);
    padding: 0;
}
.btn-icon:hover { background: var(--bs-secondary-bg); }

/* ===================== Cards ===================== */
.card { border: none; border-radius: 16px; box-shadow: var(--card-shadow); }
.card-stat { border-left: 4px solid; border-radius: 12px; }
.stat-icon {
    width: 56px; height: 56px; border-radius: 14px;
    display: flex; align-items: center; justify-content: center; font-size: 1.5rem;
}

/* ===================== Absensi Cards ===================== */
.absensi-card { border-radius: 20px; overflow: hidden; }
.absensi-card .card-header {
    background: linear-gradient(135deg, var(--primary) 0%, #7c3aed 100%);
    color: white; border: none; padding: 1.5rem;
}

/* ===================== Camera ===================== */
.camera-wrapper {
    border-radius: 16px; overflow: hidden; background: #000;
    aspect-ratio: 4/3; display: flex; align-items: center; justify-content: center;
}
#cameraFeed, #capturedPhoto { width: 100%; height: 100%; object-fit: cover; display: block; }
.camera-overlay {
    position: absolute; bottom: 0; left: 0; right: 0; padding: 1rem;
    background: linear-gradient(0deg, rgba(0,0,0,.7), transparent);
}

/* ===================== Tables ===================== */
.table { border-radius: 12px; overflow: hidden; }
.table thead th { font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }

/* ===================== Timeline ===================== */
.timeline { position: relative; padding-left: 30px; }
.timeline::before { content: ''; position: absolute; left: 10px; top: 0; bottom: 0; width: 2px; background: var(--bs-border-color); }
.timeline-item { position: relative; margin-bottom: 1.5rem; }
.timeline-item::before { content: ''; position: absolute; left: -24px; top: 4px; width: 12px; height: 12px; border-radius: 50%; background: var(--primary); border: 2px solid var(--bs-body-bg); }

/* ===================== Notifications ===================== */
.notif-dropdown { min-width: 340px; max-height: 400px; overflow-y: auto; }
.notif-dropdown .dropdown-header { background: var(--bs-secondary-bg); border-bottom: 1px solid var(--bs-border-color); padding: .75rem 1rem; position: sticky; top: 0; }
.notif-item.unread { background: rgba(67,97,238,.06); }

/* ===================== Loading ===================== */
.loading-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,.5);
    z-index: 9999; display: flex; align-items: center; justify-content: center;
}

/* ===================== Map ===================== */
#mapContainer { height: 300px; border-radius: 12px; overflow: hidden; }

/* ===================== QR ===================== */
.qr-container {
    background: white; padding: 1.5rem; border-radius: 16px;
    display: inline-block; box-shadow: var(--card-shadow);
}

/* ===================== Dark Mode ===================== */
[data-bs-theme="dark"] .sidebar-wrapper { background: #0d1117; }
[data-bs-theme="dark"] .card { background: #161b22; }
[data-bs-theme="dark"] .topbar { background: #0d1117; border-color: #30363d !important; }

/* ===================== Animations ===================== */
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .5; } }
.animate-pulse { animation: pulse 2s infinite; }
@keyframes slideInUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
.slide-in-up { animation: slideInUp .4s ease; }

/* ===================== Clock ===================== */
#realtimeClock {
    font-size: 2.5rem; font-weight: 700; font-variant-numeric: tabular-nums;
    letter-spacing: 2px;
    background: linear-gradient(135deg, var(--primary), #7c3aed);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}

/* ===================== Profile ===================== */
.profile-avatar-wrapper { position: relative; display: inline-block; }
.profile-avatar { width: 120px; height: 120px; object-fit: cover; border-radius: 50%; border: 4px solid var(--primary); }
.avatar-edit-btn {
    position: absolute; bottom: 5px; right: 5px; width: 32px; height: 32px;
    border-radius: 50%; background: var(--primary); color: white; border: none;
    display: flex; align-items: center; justify-content: center; cursor: pointer; font-size: .8rem;
}

/* ===================== Forms ===================== */
.form-control, .form-select { border-radius: 10px; padding: .6rem 1rem; }
.form-control:focus, .form-select:focus { border-color: var(--primary); box-shadow: 0 0 0 .25rem rgba(67,97,238,.2); }
.btn { border-radius: 10px; font-weight: 500; }
.btn-primary { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover { background: var(--secondary); border-color: var(--secondary); }


/* ===================== SIDEBAR MOBILE FIX ===================== */
/* Overlay */
#sidebarOverlay {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.55);
    z-index: 1045;
}
#sidebarOverlay.show { display: block; }

@media (max-width: 991.98px) {
    /* Sembunyikan sidebar di mobile */
    .sidebar-wrapper {
        position: fixed !important;
        top: 0; left: 0;
        height: 100%;
        width: 270px !important;
        z-index: 1050;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }

    /* Tampilkan sidebar saat toggle */
    .sidebar-wrapper.mobile-open {
        transform: translateX(0);
        box-shadow: 4px 0 20px rgba(0,0,0,0.3);
    }

    /* Content full width */
    #page-content-wrapper {
        width: 100% !important;
        margin-left: 0 !important;
    }

    /* Nonaktifkan collapsed di mobile */
    .sidebar-wrapper.collapsed {
        width: 270px !important;
        transform: translateX(-100%);
    }
    .sidebar-wrapper.collapsed.mobile-open {
        transform: translateX(0);
    }
    .sidebar-wrapper.collapsed .sidebar-heading span,
    .sidebar-wrapper.collapsed .sidebar-user,
    .sidebar-wrapper.collapsed .menu-header,
    .sidebar-wrapper.collapsed .sidebar-menu li a span,
    .sidebar-wrapper.collapsed .badge { display: unset; }
    .sidebar-wrapper.collapsed .sidebar-menu li a { justify-content: flex-start; padding: 10px 16px; }
}

@media (min-width: 992px) {
    /* Desktop: sidebar normal */
    .sidebar-wrapper {
        position: sticky !important;
        top: 0;
        height: 100vh;
        align-self: flex-start;
        transform: none !important;
    }
    #sidebarOverlay { display: none !important; }
}

/* ===================== FINAL MODAL SCROLL FIX ===================== */
.modal-dialog-scrollable {
    max-height: calc(100vh - 56px) !important;
    height: calc(100vh - 56px) !important;
}

.modal-dialog-scrollable .modal-content {
    max-height: 100% !important;
    height: 100% !important;
    overflow: hidden !important;
    display: flex !important;
    flex-direction: column !important;
}

.modal-dialog-scrollable .modal-content > form {
    display: flex !important;
    flex-direction: column !important;
    flex: 1 !important;
    overflow: hidden !important;
    min-height: 0 !important;
}

.modal-dialog-scrollable .modal-header,
.modal-dialog-scrollable .modal-footer {
    flex: 0 0 auto !important;
}

.modal-dialog-scrollable .modal-body {
    overflow-y: auto !important;
    flex: 1 !important;
    min-height: 0 !important;
    -webkit-overflow-scrolling: touch !important;
}