/* =========================================================
   e-Jurnal PKL v2.0 - Modern, Minimalist & High-Density UI
   Clean, Compact & Fully Responsive Across All Devices
   ========================================================= */

:root {
    /* Color Palette - Modern Minimalist Slate & Indigo */
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-light: #eff6ff;
    --primary-gradient: linear-gradient(135deg, #1e40af 0%, #3b82f6 100%);
    
    --sidebar-bg: #0b1120;
    --sidebar-surface: #111827;
    --sidebar-border: rgba(255, 255, 255, 0.07);
    --sidebar-text: #94a3b8;
    --sidebar-text-hover: #f8fafc;
    --sidebar-active-bg: rgba(37, 99, 235, 0.16);
    --sidebar-active-border: #38bdf8;
    
    --bg-main: #f8fafc;
    --surface: #ffffff;
    --border-color: #e2e8f0;
    --border-subtle: #f1f5f9;
    
    --text-main: #0f172a;
    --text-muted: #64748b;
    --text-light: #94a3b8;
    
    --success: #059669;
    --success-light: #ecfdf5;
    --warning: #d97706;
    --warning-light: #fffbeb;
    --danger: #dc2626;
    --danger-light: #fef2f2;
    --info: #0284c7;
    --info-light: #f0f9ff;
    
    --shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.03);
    --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.05), 0 1px 2px -1px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.06), 0 2px 4px -2px rgba(0, 0, 0, 0.04);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
    
    --radius-sm: 4px;
    --radius-md: 6px;
    --radius-lg: 8px;
    --radius-xl: 12px;
}

/* =========================================================
   BASE & TYPOGRAPHY
   ========================================================= */
* {
    box-sizing: border-box;
}

body {
    font-family: 'Poppins', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 0.835rem;
    line-height: 1.45;
    background-color: var(--bg-main);
    color: var(--text-main);
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6, .h1, .h2, .h3, .h4, .h5, .h6 {
    font-weight: 600;
    color: var(--text-main);
    letter-spacing: -0.015em;
    margin-bottom: 0.35rem;
}

h4, .h4 { font-size: 1.15rem; }
h5, .h5 { font-size: 0.98rem; }
h6, .h6 { font-size: 0.88rem; }

.small, small {
    font-size: 0.75rem;
}

.text-muted {
    color: var(--text-muted) !important;
}

/* =========================================================
   LAYOUT SHELL (SIDEBAR, TOPBAR, MAIN)
   ========================================================= */
.sidebar {
    width: 240px;
    height: 100vh;
    max-height: 100vh;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 1040;
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    border-right: 1px solid var(--sidebar-border);
    overflow-y: auto;
    flex-shrink: 0;
}

.sidebar .nav-link {
    color: var(--sidebar-text);
    padding: 6px 12px;
    font-size: 0.81rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    border-radius: var(--radius-md);
    margin: 1px 8px;
    transition: all 0.15s ease;
    text-decoration: none;
}

.sidebar .nav-link i {
    font-size: 1rem;
    margin-right: 9px;
    width: 20px;
    text-align: center;
    color: #64748b;
    transition: color 0.15s ease;
}

.sidebar .nav-link:hover {
    color: var(--sidebar-text-hover);
    background: rgba(255, 255, 255, 0.05);
}

.sidebar .nav-link:hover i {
    color: #38bdf8;
}

.sidebar .nav-link.active {
    color: #ffffff;
    background: var(--sidebar-active-bg);
    border-left: 3px solid var(--sidebar-active-border);
    font-weight: 600;
}

.sidebar .nav-link.active i {
    color: #38bdf8;
}

.sidebar-heading {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #64748b;
    padding: 10px 14px 4px;
    font-weight: 600;
}

.sidebar-toggle-heading {
    cursor: pointer;
    user-select: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: color 0.2s;
    border-radius: var(--radius-md);
    margin: 2px 8px 0;
    padding: 6px 10px;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    color: #94a3b8;
}

.sidebar-toggle-heading:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.06);
}

.sidebar-toggle-heading .heading-chevron {
    transition: transform 0.2s ease;
    font-size: 0.7rem;
}

.sidebar-toggle-heading[aria-expanded="false"] .heading-chevron {
    transform: rotate(-90deg);
}

.main-wrapper {
    margin-left: 240px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-left 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    background-color: var(--bg-main);
}

.top-navbar {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--border-color) !important;
    padding: 8px 18px;
    position: sticky;
    top: 0;
    z-index: 1020;
    height: 52px;
}

.content-body {
    padding: 16px 20px;
    flex: 1;
}

/* Desktop sidebar collapsed state */
body.sidebar-collapsed .sidebar {
    transform: translateX(-240px);
}

body.sidebar-collapsed .main-wrapper {
    margin-left: 0;
}

/* Sidebar Backdrop on Mobile */
.sidebar-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(2px);
    z-index: 1025;
    display: none;
    opacity: 0;
    transition: opacity 0.25s ease;
}

.sidebar-backdrop.show {
    display: block;
    opacity: 1;
}

/* =========================================================
   HIGH DENSITY CARDS & CONTAINERS
   ========================================================= */
.card {
    background: var(--surface);
    border: 1px solid var(--border-color) !important;
    border-radius: var(--radius-lg) !important;
    box-shadow: var(--shadow-xs) !important;
    margin-bottom: 0.85rem !important;
    transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.card:hover {
    box-shadow: var(--shadow-sm) !important;
}

.card-header {
    background: #ffffff;
    border-bottom: 1px solid var(--border-subtle);
    padding: 9px 14px !important;
    font-size: 0.85rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-body {
    padding: 12px 14px !important;
}

.card-footer {
    background: #ffffff;
    border-top: 1px solid var(--border-subtle);
    padding: 8px 14px !important;
}

/* Stat Cards (Modern Compact Metric Tiles) */
.card-stat {
    position: relative;
    overflow: hidden;
    padding: 11px 13px !important;
    border-radius: var(--radius-lg) !important;
}

.card-stat .stat-label {
    font-size: 0.72rem;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 2px;
}

.card-stat .stat-value {
    font-size: 1.35rem;
    font-weight: 700;
    line-height: 1.15;
    color: var(--text-main);
}

.card-stat .stat-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
}

/* =========================================================
   ULTRA-COMPACT & DENSE DATA TABLES
   ========================================================= */
.table-responsive {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    background: var(--surface);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table {
    margin-bottom: 0 !important;
    font-size: 0.81rem;
    width: 100%;
}

.table th {
    background-color: #f8fafc !important;
    color: #475569 !important;
    font-size: 0.71rem !important;
    font-weight: 600 !important;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 7px 10px !important;
    vertical-align: middle;
    border-bottom: 1px solid var(--border-color) !important;
    white-space: nowrap;
}

.table td {
    padding: 6px 10px !important;
    vertical-align: middle;
    border-bottom: 1px solid var(--border-subtle) !important;
    color: #1e293b;
    line-height: 1.4;
}

.table tbody tr:hover {
    background-color: rgba(241, 245, 249, 0.6) !important;
}

.table tbody tr:last-child td {
    border-bottom: none !important;
}

/* Compact Table Action Buttons */
.table .btn, .btn-action {
    padding: 0.22rem 0.45rem !important;
    font-size: 0.74rem !important;
    line-height: 1.25 !important;
    border-radius: var(--radius-sm) !important;
    font-weight: 500;
}

.btn-group-action {
    display: inline-flex;
    align-items: center;
    gap: 3px;
}

/* =========================================================
   COMPACT FORMS, INPUTS & FILTERS
   ========================================================= */
.form-label {
    font-size: 0.77rem;
    font-weight: 500;
    margin-bottom: 0.25rem;
    color: #334155;
}

.form-control, .form-select {
    font-size: 0.82rem !important;
    padding: 0.38rem 0.7rem !important;
    border-radius: var(--radius-md) !important;
    border: 1px solid #cbd5e1 !important;
    color: #0f172a;
    background-color: #ffffff;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary) !important;
    box-shadow: 0 0 0 2.5px rgba(37, 99, 235, 0.15) !important;
    outline: none;
}

.input-group-text {
    font-size: 0.8rem;
    padding: 0.38rem 0.65rem;
    background-color: #f8fafc;
    border: 1px solid #cbd5e1;
    color: #64748b;
}

.form-control-sm, .form-select-sm, .input-group-sm > .form-control, .input-group-sm > .form-select, .input-group-sm > .input-group-text {
    font-size: 0.78rem !important;
    padding: 0.28rem 0.55rem !important;
    border-radius: var(--radius-md) !important;
}

/* =========================================================
   BUTTONS (COMPACT & MODERN)
   ========================================================= */
.btn {
    font-size: 0.81rem;
    font-weight: 500;
    padding: 0.38rem 0.75rem;
    border-radius: var(--radius-md);
    transition: all 0.15s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    line-height: 1.4;
}

.btn:active {
    transform: scale(0.98);
}

.btn-sm {
    font-size: 0.75rem !important;
    padding: 0.26rem 0.55rem !important;
    border-radius: var(--radius-sm) !important;
}

.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
    color: #ffffff;
}

.btn-primary:hover, .btn-primary:focus {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
    color: #ffffff;
    box-shadow: 0 2px 6px rgba(37, 99, 235, 0.25);
}

.btn-outline-primary {
    border-color: #cbd5e1;
    color: #2563eb;
    background: #ffffff;
}

.btn-outline-primary:hover {
    background: #eff6ff;
    border-color: #2563eb;
    color: #1d4ed8;
}

.btn-outline-secondary {
    border-color: #cbd5e1;
    color: #475569;
    background: #ffffff;
}

.btn-outline-secondary:hover {
    background: #f1f5f9;
    border-color: #94a3b8;
    color: #1e293b;
}

/* =========================================================
   CLEAN BADGES
   ========================================================= */
.badge {
    font-size: 0.69rem !important;
    font-weight: 500 !important;
    padding: 0.25em 0.55em !important;
    border-radius: 4px !important;
    letter-spacing: 0.02em;
}

.badge-role-admin { background-color: #7c3aed; color: #ffffff; }
.badge-role-guru  { background-color: #0284c7; color: #ffffff; }
.badge-role-siswa { background-color: #059669; color: #ffffff; }
.badge-role-dudi  { background-color: #ea580c; color: #ffffff; }

/* Status Badges with High Contrast Readability */
.badge-status-disetujui, .badge.bg-success {
    background-color: #059669 !important;
    color: #ffffff !important;
    border: none !important;
    font-weight: 600;
}

.badge.bg-success.bg-opacity-10,
.badge.bg-success.bg-opacity-15,
.badge.bg-success.bg-opacity-20,
.badge.bg-success.bg-opacity-25 {
    background-color: #ecfdf5 !important;
    color: #064e3b !important; /* Deep contrast dark green */
    border: 1px solid #a7f3d0 !important;
    font-weight: 600;
}

.alert-success {
    background-color: #ecfdf5 !important;
    border-color: #a7f3d0 !important;
    color: #064e3b !important; /* Deep contrast dark green */
}
.alert-success hr {
    border-top-color: #a7f3d0 !important;
}
.alert-success .alert-link,
.alert-success strong {
    color: #022c22 !important;
}

.badge-status-diajukan, .badge.bg-warning {
    background-color: #fffbeb !important;
    color: #b45309 !important;
    border: 1px solid #fde68a !important;
}

.badge-status-ditolak, .badge.bg-danger {
    background-color: #fef2f2 !important;
    color: #b91c1c !important;
    border: 1px solid #fecaca !important;
}

.badge-status-draft, .badge.bg-secondary {
    background-color: #f1f5f9 !important;
    color: #475569 !important;
    border: 1px solid #cbd5e1 !important;
}

/* =========================================================
   COMPACT MODALS
   ========================================================= */
.modal-content {
    border-radius: var(--radius-lg) !important;
    border: 1px solid var(--border-color) !important;
    box-shadow: var(--shadow-lg) !important;
    overflow: hidden;
}

.modal-header {
    padding: 10px 16px !important;
    background-color: #f8fafc;
    border-bottom: 1px solid var(--border-color) !important;
}

.modal-header .modal-title {
    font-size: 0.94rem;
    font-weight: 600;
}

.modal-body {
    padding: 14px 16px !important;
    font-size: 0.83rem;
}

.modal-footer {
    padding: 8px 16px !important;
    background-color: #f8fafc;
    border-top: 1px solid var(--border-color) !important;
}

/* =========================================================
   COMPACT PAGINATION
   ========================================================= */
.pagination {
    margin-bottom: 0 !important;
    gap: 3px;
}

.pagination .page-item .page-link {
    font-size: 0.76rem !important;
    padding: 0.22rem 0.55rem !important;
    border-radius: 4px !important;
    color: #475569;
    border: 1px solid #e2e8f0;
    transition: all 0.15s ease;
}

.pagination .page-item.active .page-link {
    background-color: var(--primary);
    border-color: var(--primary);
    color: #ffffff;
    font-weight: 600;
}

.pagination .page-item .page-link:hover {
    background-color: #f1f5f9;
    color: #1e293b;
}

/* =========================================================
   ALERTS (COMPACT & MODERN)
   ========================================================= */
.alert {
    padding: 8px 14px !important;
    font-size: 0.82rem !important;
    border-radius: var(--radius-md) !important;
    margin-bottom: 0.85rem !important;
    border-width: 1px !important;
}

.alert-dismissible .btn-close {
    padding: 0.85rem 1rem !important;
}

/* =========================================================
   AJAX ASYNCHRONOUS ENGINE STYLING
   ========================================================= */
#ajaxProgressBar {
    position: fixed;
    top: 0;
    left: 0;
    width: 0%;
    height: 3px;
    background: linear-gradient(90deg, #38bdf8 0%, #3b82f6 50%, #6366f1 100%);
    box-shadow: 0 0 10px rgba(56, 189, 248, 0.8), 0 0 5px rgba(59, 130, 246, 0.5);
    z-index: 999999;
    transition: width 0.2s ease, opacity 0.3s ease;
    pointer-events: none;
    opacity: 0;
}

.ajax-loading-content {
    opacity: 0.55;
    filter: grayscale(12%);
    transition: opacity 0.15s ease-in-out, filter 0.15s ease-in-out;
    pointer-events: none;
}

#appMainContent {
    transition: opacity 0.18s ease-in-out;
}

/* Micro-animations */
@keyframes fadeInContent {
    from {
        opacity: 0.75;
        transform: translateY(3px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.content-body {
    animation: fadeInContent 0.2s ease-out;
}

/* =========================================================
   CUSTOM MINIMALIST SCROLLBAR
   ========================================================= */
::-webkit-scrollbar {
    width: 5px;
    height: 5px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* =========================================================
   MULTI-DEVICE RESPONSIVENESS MATRIX
   (Mobile Phones, Phablets, Tablets, Laptops, Desktops)
   ========================================================= */

/* Extra Small Phones (<= 480px) */
@media (max-width: 480px) {
    .content-body {
        padding: 8px 6px !important;
    }
    
    .top-navbar {
        padding: 6px 10px !important;
        height: 48px;
    }
    
    .card-body {
        padding: 10px 10px !important;
    }
    
    .table th, .table td {
        padding: 5px 7px !important;
        font-size: 0.76rem !important;
    }
    
    /* Tombol CRUD stack atau compact */
    .btn-group-action {
        gap: 2px;
    }
    
    .btn-group-action .btn {
        padding: 0.18rem 0.32rem !important;
        font-size: 0.7rem !important;
    }
    
    /* Filter inputs full width */
    .filter-card .col-12, .filter-card .col-md-3, .filter-card .col-md-9 {
        width: 100% !important;
    }
    
    /* Stat numbers */
    .card-stat .stat-value {
        font-size: 1.15rem !important;
    }
    
    /* Modal responsive fit */
    .modal-dialog {
        margin: 0.4rem;
        max-width: calc(100% - 0.8rem) !important;
    }
    
    .modal-body {
        max-height: 75vh;
        overflow-y: auto;
    }
    
    /* Header action buttons wrap */
    .page-header-actions {
        flex-direction: column;
        align-items: stretch !important;
        width: 100%;
        gap: 6px;
    }
    
    .page-header-actions .btn {
        width: 100%;
    }
}

/* Phones & Phablets (<= 767.98px) */
@media (max-width: 767.98px) {
    .content-body {
        padding: 10px 10px;
    }

    h4, .h4 {
        font-size: 1.05rem;
    }

    /* Stack filters neatly */
    .row.g-2 > [class*="col-"] {
        margin-bottom: 2px;
    }

    /* Video viewfinder in camera modal */
    .modal-body video#videoElement {
        max-height: 44vh !important;
    }
}

/* Mobile & Tablet Combined (<= 991.98px) */
@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%) !important;
        margin-left: 0 !important;
        z-index: 1040;
        box-shadow: 0 0 25px rgba(0, 0, 0, 0.45);
    }
    .sidebar.show {
        transform: translateX(0) !important;
    }
    .main-wrapper {
        margin-left: 0 !important;
        width: 100% !important;
    }
    .top-navbar {
        padding: 6px 14px;
    }
}

/* Tablets Landscape & Laptops (992px to 1199.98px) */
@media (min-width: 992px) and (max-width: 1199.98px) {
    .content-body {
        padding: 14px 18px;
    }
}

/* Large Screens & Desktop Monitors (>= 1200px) */
@media (min-width: 1200px) {
    .content-body {
        padding: 18px 24px;
    }
}

/* =========================================================
   RESPONSIVE MAPS & WEBRTC CAMERA UTILITIES
   ========================================================= */
#monitoringMap, #openStreetGpsMap, #openStreetEditMap, #profilMagangMap, #openStreetDudiMap {
    width: 100% !important;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
}

@media (max-width: 576px) {
    #monitoringMap {
        height: 320px !important;
    }
    #openStreetGpsMap, #openStreetEditMap, #profilMagangMap, #openStreetDudiMap {
        height: 220px !important;
    }
    .modal-body video#videoElement, .modal-body video#videoElementEdit {
        max-height: 40vh !important;
    }
}