/* ============================================
   RAPORT TK DIGITAL - STYLESHEET UTAMA
   Seluruh styling terpisah dari file PHP
   ============================================ */

/* --- CSS Variables --- */
:root {
    --primary: #0d6efd;
    --primary-dark: #0a58ca;
    --secondary: #6c757d;
    --success: #10b981;
    --success-dark: #059669;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;
    --sidebar-bg: #1e293b;
    --sidebar-hover: #334155;
    --sidebar-active: #0d6efd;
    --sidebar-text: #cbd5e1;
    --sidebar-width: 260px;
    --topbar-height: 60px;
    --body-bg: #f1f5f9;
    --card-shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
    --card-shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
    --radius: 8px;
    --radius-lg: 12px;
    --transition: all 0.2s ease;
}

/* --- Reset & Base --- */
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--body-bg);
    color: #1e293b;
    font-size: 14px;
    line-height: 1.6;
    overflow-x: hidden;
}
a { color: var(--primary); text-decoration: none; transition: var(--transition); }
a:hover { color: var(--primary-dark); }

/* --- Sidebar --- */
.sidebar {
    position: fixed;
    top: 0; left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    z-index: 1040;
    overflow-y: auto;
    transition: transform 0.3s ease;
}
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    font-size: 15px;
    font-weight: 700;
    color: #fff;
    min-height: var(--topbar-height);
}
.sidebar-brand img {
    width: 36px; height: 36px;
    border-radius: 8px;
    object-fit: cover;
    background: rgba(255,255,255,0.1);
}
.sidebar-menu { list-style: none; padding: 12px 0; }
.sidebar-menu .menu-label {
    padding: 12px 20px 6px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: #64748b;
}
.sidebar-menu li a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    color: var(--sidebar-text);
    font-size: 13.5px;
    font-weight: 500;
    transition: var(--transition);
    border-left: 3px solid transparent;
}
.sidebar-menu li a:hover {
    background: var(--sidebar-hover);
    color: #fff;
    border-left-color: rgba(13,110,253,0.5);
}
.sidebar-menu li a.active {
    background: rgba(13,110,253,0.15);
    color: #fff;
    border-left-color: var(--sidebar-active);
}
.sidebar-menu li a .menu-icon {
    width: 20px;
    text-align: center;
    font-size: 15px;
    flex-shrink: 0;
}

/* --- Main Content --- */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    transition: margin-left 0.3s ease;
}

/* --- Topbar --- */
.topbar {
    height: var(--topbar-height);
    background: #fff;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 1030;
}
.topbar-left { display: flex; align-items: center; gap: 16px; }
.topbar-left h5 { font-size: 16px; font-weight: 700; color: #1e293b; margin: 0; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.topbar-right .user-badge {
    display: flex; align-items: center; gap: 8px;
    padding: 6px 14px;
    background: #f1f5f9;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    color: #475569;
}
.btn-toggle-sidebar {
    display: none;
    background: none; border: none;
    font-size: 22px; color: #475569;
    cursor: pointer; padding: 4px;
}

/* --- Content Area --- */
.content-area { padding: 24px; }

/* --- Cards --- */
.card-custom {
    background: #fff;
    border-radius: var(--radius-lg);
    box-shadow: var(--card-shadow);
    border: 1px solid #e2e8f0;
    overflow: visible;
}
.card-custom .card-header-custom {
    padding: 16px 20px;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #fff;
}
.card-custom .card-header-custom h6 {
    font-size: 15px;
    font-weight: 700;
    color: #1e293b;
    margin: 0;
}
.card-custom .card-body-custom { padding: 20px; }

/* --- Stat Cards --- */
.stat-card {
    background: #fff;
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--card-shadow);
    border: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: var(--transition);
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--card-shadow-lg); }
.stat-icon {
    width: 52px; height: 52px;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 22px; color: #fff; flex-shrink: 0;
}
.stat-icon.bg-blue { background: linear-gradient(135deg, #3b82f6, #2563eb); }
.stat-icon.bg-green { background: linear-gradient(135deg, #10b981, #059669); }
.stat-icon.bg-orange { background: linear-gradient(135deg, #f59e0b, #d97706); }
.stat-icon.bg-purple { background: linear-gradient(135deg, #8b5cf6, #7c3aed); }
.stat-icon.bg-red { background: linear-gradient(135deg, #ef4444, #dc2626); }
.stat-icon.bg-teal { background: linear-gradient(135deg, #14b8a6, #0d9488); }
.stat-info h3 { font-size: 24px; font-weight: 800; color: #1e293b; margin: 0; line-height: 1.2; }
.stat-info p { font-size: 12px; color: #64748b; margin: 2px 0 0; font-weight: 500; }

/* --- Tables --- */
.table-custom { width: 100%; border-collapse: separate; border-spacing: 0; }
.table-custom thead th {
    background: #f8fafc;
    padding: 12px 14px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #475569;
    border-bottom: 2px solid #e2e8f0;
    white-space: nowrap;
}
.table-custom tbody td {
    padding: 10px 14px;
    border-bottom: 1px solid #f1f5f9;
    font-size: 13px;
    color: #334155;
    vertical-align: middle;
}
.table-custom tbody tr:hover { background: #f8fafc; }
.table-custom tbody tr:last-child td { border-bottom: none; }

/* --- Avatar --- */
.avatar {
    width: 38px; height: 38px;
    border-radius: 10px;
    object-fit: cover;
    background: #e2e8f0;
    border: 2px solid #f1f5f9;
}
.avatar-sm { width: 30px; height: 30px; border-radius: 8px; }
.avatar-lg { width: 60px; height: 60px; border-radius: 14px; }
.avatar-xl { width: 100px; height: 100px; border-radius: 16px; }

/* --- Buttons --- */
.btn-action {
    padding: 5px 10px;
    font-size: 12px;
    border-radius: 6px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.btn-action:hover { opacity: 0.85; transform: translateY(-1px); }
.btn-edit { background: #dbeafe; color: #1d4ed8; }
.btn-delete { background: #fee2e2; color: #dc2626; }
.btn-view { background: #d1fae5; color: #059669; }
.btn-print { background: #fef3c7; color: #d97706; }

/* --- Star Icons --- */
.star-icon { font-size: 18px; }
.star-filled { color: #f70505; }
.star-empty { color: #e2e8f0; }
.star-lg .star-icon { font-size: 24px; }

/* --- Level Badges --- */
.level-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px; height: 28px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 800;
}
.level-a { background: #d1fae5; color: #059669; }
.level-b { background: #dbeafe; color: #2563eb; }
.level-c { background: #fef3c7; color: #d97706; }

/* --- Form Custom --- */
.form-label-custom {
    font-size: 13px;
    font-weight: 600;
    color: #374151;
    margin-bottom: 6px;
}
.form-control, .form-select {
    border-radius: var(--radius);
    border: 1.5px solid #d1d5db;
    padding: 8px 12px;
    font-size: 13.5px;
    transition: var(--transition);
}
.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(13,110,253,0.12);
}

/* --- Progress Bar Ekstra --- */
.ekstra-progress-bar {
    height: 8px;
    background: #e2e8f0;
    border-radius: 4px;
    overflow: hidden;
}
.ekstra-progress-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.5s ease;
}

/* --- Modal Custom --- */
.modal-header-custom {
    background: #f8fafc;
    border-bottom: 2px solid #e2e8f0;
    padding: 16px 20px;
}
.modal-header-custom .modal-title { font-size: 16px; font-weight: 700; }

/* --- Login Page --- */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 50%, #0f172a 100%);
    padding: 20px;
}
.login-card {
    width: 100%;
    max-width: 420px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 25px 50px rgba(0,0,0,0.25);
    overflow: hidden;
}
.login-header {
    background: linear-gradient(135deg, #0d6efd, #0a58ca);
    padding: 30px;
    text-align: center;
    color: #fff;
}
.login-header h3 { font-size: 20px; font-weight: 800; margin-bottom: 4px; }
.login-header p { font-size: 13px; opacity: 0.85; margin: 0; }
.login-body { padding: 30px; }

/* --- Cetak Raport --- */
.raport-page {
    width: 210mm;
    min-height: 297mm;
    margin: 0 auto;
    background: #fff;
    padding: 15mm 20mm;
    font-size: 11px;
    line-height: 1.5;
    color: #000;
}
.raport-kop {
    text-align: center;
    border-bottom: 3px double #000;
    padding-bottom: 10px;
    margin-bottom: 15px;
}
.raport-kop h2 { font-size: 16px; font-weight: 800; margin: 0 0 2px; letter-spacing: 1px; }
.raport-kop p { font-size: 10px; margin: 0; }
.raport-section { margin-bottom: 14px; }
.raport-section h4 {
    font-size: 12px; font-weight: 700;
    background: #e2e8f0;
    padding: 6px 10px;
    border-radius: 4px;
    margin-bottom: 8px;
}
.raport-table { width: 100%; border-collapse: collapse; margin-bottom: 8px; }
.raport-table th, .raport-table td {
    border: 1px solid #94a3b8;
    padding: 5px 8px;
    font-size: 10.5px;
}
.raport-table th { background: #f1f5f9; font-weight: 700; text-align: center; }
.raport-table td { vertical-align: top; }
.raport-foto-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 10px;
}
.raport-foto-item { text-align: center; }
.raport-foto-item img {
    width: 100%;
    height: 80px;
    object-fit: cover;
    border-radius: 4px;
    border: 1px solid #cbd5e1;
}
.raport-foto-item p { font-size: 9px; color: #475569; margin: 3px 0 0; }
.raport-ttd {
    display: flex;
    justify-content: space-between;
    margin-top: 30px;
    font-size: 11px;
}
.raport-ttd .ttd-box { text-align: center; width: 180px; }
.raport-ttd .ttd-box .ttd-space { height: 60px; }

/* ============================================
   IDENTITAS SISWA (Komponen)
   ============================================ */
.idt-row { display: flex; padding: 4px 0; border-bottom: 1px solid #f0f0f0; }
.idt-row:last-child { border-bottom: none; }
.idt-label { width: 150px; min-width: 150px; font-weight: 600; color: #555; font-size: 0.88rem; }
.idt-value { flex: 1; font-size: 0.88rem; color: #222; }
.idt-foto { width: 130px; height: 160px; border-radius: 8px; border: 2px solid #dee2e6; object-fit: cover; }
.idt-foto-ph { width: 130px; height: 160px; border-radius: 8px; border: 2px dashed #ced4da; display: flex; align-items: center; justify-content: center; background: #f8f9fa; }

/* ============================================
   COVER RAPORT
   ============================================ */
.cvr-wrap { position: relative; min-height: 267mm; display: flex; flex-direction: column; padding: 9mm; }
.cvr-border-outer { position: absolute; top: 5mm; left: 5mm; right: 5mm; bottom: 5mm; border: 2.5px solid #1a237e; border-radius: 4px; pointer-events: none; }
.cvr-border-inner { position: absolute; top: 7mm; left: 7mm; right: 7mm; bottom: 7mm; border: 0.8px solid #1a237e; border-radius: 3px; pointer-events: none; }
.cvr-top { text-align: center; margin-bottom: 5mm; }
.cvr-logo { width: 60px; height: 60px; object-fit: contain; }
.cvr-sekolah { font-size: 15pt; font-weight: 700; color: #1a237e; letter-spacing: 1.5px; text-transform: uppercase; line-height: 1.3; margin: 2mm 0 0; }
.cvr-npsn { font-size: 8pt; color: #555; margin-top: 1mm; }
.cvr-alamat { font-size: 7.5pt; color: #666; margin-top: 1mm; }
.cvr-line { border: none; height: 2px; background: linear-gradient(to right, transparent, #c5a028, transparent); margin: 4mm 0; }
.cvr-line-sm { border: none; height: 0.8px; background: linear-gradient(to right, transparent, #c5a028, transparent); margin: 2mm 0; }
.cvr-judul { text-align: center; margin: 5mm 0; }
.cvr-judul h2 { font-size: 17pt; font-weight: 700; color: #1a237e; letter-spacing: 3px; text-transform: uppercase; margin: 0; line-height: 1.4; }
.cvr-judul p { font-size: 9.5pt; color: #777; margin: 1mm 0 0; letter-spacing: 1px; }
.cvr-info { text-align: center; font-size: 9.5pt; color: #333; margin-bottom: 3mm; }
.cvr-data { flex: 1; display: flex; align-items: center; justify-content: center; }
.cvr-data-inner { width: 100%; }
.cvr-data-row { display: flex; padding: 2.5mm 0; border-bottom: 0.5px solid #e0e0e0; }
.cvr-data-row:last-child { border-bottom: none; }
.cvr-dl { width: 65mm; min-width: 65mm; color: #555; font-size: 10pt; }
.cvr-dv { flex: 1; color: #111; font-weight: 600; font-size: 10pt; }
.cvr-dv.big { font-size: 15pt; font-weight: 700; color: #1a237e; letter-spacing: 1px; text-transform: uppercase; padding-top: 1mm; }
.cvr-ttd { text-align: right; padding-right: 5mm; margin-top: 3mm; }
.cvr-ttd-place { font-size: 9pt; color: #333; }
.cvr-ttd-jab { font-size: 9pt; color: #333; margin-top: 1mm; }
.cvr-ttd-space { height: 26mm; }
.cvr-ttd-name { font-size: 10pt; font-weight: 700; color: #111; text-decoration: underline; text-underline-offset: 2px; }
.cvr-ttd-nip { font-size: 8pt; color: #555; margin-top: 1mm; }
/* --- Print --- */
@media print {
    .sidebar, .topbar, .no-print { display: none !important; }
    .main-content { margin-left: 0 !important; }
    .content-area { padding: 0 !important; }
    .raport-page { box-shadow: none; margin: 0; }
    body { background: #fff; }
    @page { size: A4; margin: 0; }
}

/* --- Responsive --- */
@media (max-width: 991.98px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.show { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .btn-toggle-sidebar { display: block; }
    .sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.4);
        z-index: 1035;
    }
    .sidebar-overlay.show { display: block; }
}
@media (max-width: 575.98px) {
    .content-area { padding: 16px; }
    .stat-card { padding: 14px; }
    .stat-icon { width: 42px; height: 42px; font-size: 18px; }
    .stat-info h3 { font-size: 20px; }
    .raport-page { padding: 8mm 10mm; width: 100%; }
}

/* --- Ekstra Card --- */
.ekstra-stat-card {
    background: #fff;
    border-radius: var(--radius);
    padding: 14px 16px;
    border: 1px solid #e2e8f0;
    margin-bottom: 10px;
}
.ekstra-stat-card .ekstra-name {
    font-size: 13px; font-weight: 700; color: #1e293b; margin-bottom: 6px;
}
.ekstra-stat-card .ekstra-info {
    font-size: 12px; color: #64748b; display: flex; justify-content: space-between;
}

/* --- Animations --- */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}
.fade-in { animation: fadeIn 0.3s ease forwards; }

/* --- Empty State --- */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: #94a3b8;
}
.empty-state .empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty-state p { font-size: 14px; }

/* --- Penilaian Tabs --- */
.penilaian-category {
    margin-bottom: 20px;
}
.penilaian-category-header {
    padding: 10px 16px;
    background: linear-gradient(135deg, #f8fafc, #f1f5f9);
    border-left: 4px solid var(--primary);
    border-radius: 0 var(--radius) var(--radius) 0;
    font-size: 14px;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 12px;
}
.penilaian-aspek {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius);
    padding: 14px 16px;
    margin-bottom: 10px;
}
.penilaian-aspek .aspek-title {
    font-size: 13px;
    font-weight: 600;
    color: #334155;
    margin-bottom: 8px;
}
.penilaian-aspek .level-options { display: flex; gap: 8px; flex-wrap: wrap; }
.penilaian-aspek .level-options label {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}
.penilaian-aspek .level-options input[type="radio"] { display: none; }
.penilaian-aspek .level-options input[type="radio"]:checked + span {
    /* handled via JS */
}
.penilaian-aspek .level-options label.selected-a { border-color: #059669; background: #d1fae5; color: #059669; }
.penilaian-aspek .level-options label.selected-b { border-color: #2563eb; background: #dbeafe; color: #2563eb; }
.penilaian-aspek .level-options label.selected-c { border-color: #d97706; background: #fef3c7; color: #d97706; }

/* --- Bintang Input --- */
.bintang-input { display: flex; gap: 6px; align-items: center; }
.bintang-input .bintang-btn {
    width: 36px; height: 36px;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    background: #fff;
    font-size: 18px;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: var(--transition);
    color: #e2e8f0;
}
.bintang-input .bintang-btn.active {
    border-color: #f59e0b;
    background: #fffbeb;
    color: #f59e0b;
}
.bintang-input .bintang-btn:hover { border-color: #f59e0b; }

/* --- CSV Example --- */
.csv-example-table {
    font-size: 11px;
    border-collapse: collapse;
    width: 100%;
    margin: 10px 0;
}
.csv-example-table th, .csv-example-table td {
    border: 1px solid #cbd5e1;
    padding: 5px 8px;
    text-align: left;
}
.csv-example-table th { background: #f1f5f9; font-weight: 700; }

/* --- Tab Custom --- */
.nav-tabs-custom .nav-link {
    border: none;
    color: #64748b;
    font-weight: 600;
    font-size: 13px;
    padding: 10px 18px;
    border-bottom: 3px solid transparent;
    border-radius: 0;
    transition: var(--transition);
}
.nav-tabs-custom .nav-link:hover { color: #1e293b; border-bottom-color: #cbd5e1; }
.nav-tabs-custom .nav-link.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    background: transparent;
}

/* --- Siswa Filter Bar --- */
.filter-bar {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}
.filter-bar .form-select, .filter-bar .form-control {
    max-width: 200px;
}
/* ============================================
   LOGIN PAGE TK - GAMBAR BACKGROUND
   ============================================ */
.login-tk {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #87CEEB;
    background-image: url('../images/login_page.png');
    background-size: cover;
    background-position: center bottom;
    background-repeat: no-repeat;
    padding: 20px;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
}
.login-tk-card {
    width: 100%;
    max-width: 360px;
    background: rgba(255,255,255,0.95);
    border-radius: 20px;
    box-shadow: 0 12px 40px rgba(0,0,0,0.15);
    overflow: hidden;
    margin-top: 5%;
}
.login-tk-header {
    background: linear-gradient(135deg, #FF9800, #F57C00);
    padding: 22px 20px;
    text-align: center;
    color: #fff;
}
.login-tk-header h3 { font-size: 22px; font-weight: 800; margin: 0 0 3px; letter-spacing: 0.5px; }
.login-tk-header p { font-size: 12px; margin: 0; opacity: 0.9; }
.login-tk-body { padding: 24px; }
.login-tk-body .form-label-custom { font-size: 12px; font-weight: 700; color: #6D4C2E; margin-bottom: 4px; }
.login-tk-body .input-group-text {
    background: #FFF3E0; border: 1.5px solid #FFCC80; color: #E8734A; font-size: 14px;
}
.login-tk-body .form-control {
    border: 1.5px solid #FFCC80; font-size: 13px; padding: 9px 12px;
    border-radius: 8px; background: #FFFCF7;
}
.login-tk-body .form-control:focus {
    border-color: #E8734A; box-shadow: 0 0 0 3px rgba(232,115,74,0.12); background: #fff;
}
.login-tk-btn {
    background: linear-gradient(135deg, #FF9800, #F57C00); color: #fff;
    border: none; border-radius: 10px; padding: 10px; font-size: 15px;
    font-weight: 700; width: 100%; cursor: pointer; letter-spacing: 1.5px;
    box-shadow: 0 4px 15px rgba(245,124,0,0.35); transition: all 0.2s;
}
.login-tk-btn:hover {
    background: linear-gradient(135deg, #FB8C00, #EF6C00);
    transform: translateY(-2px); box-shadow: 0 6px 20px rgba(245,124,0,0.45); color: #fff;
}
.login-tk-info { text-align: center; margin-top: 12px; font-size: 11px; color: #B09070; }
@media (max-width: 575px) {
    .login-tk { background-size: cover; margin-top: 0; padding: 10px; }
    .login-tk-card { margin-top: 5%; }
}
/* ============================================
   FIX MODAL TERTUTUP BACKDROP (Z-INDEX)
   Memaksa modal selalu di layer paling atas
   ============================================ */
   /* Fix specific untuk halaman pengaturan agar teks narasi tidak terpotong */
