/* ===========================
   GLOBAL & RESET
   =========================== */
:root {
  /* Premium Apple HIG Palette (Hybrid Design) */
  --bg-gradient: linear-gradient(135deg, #fdfbfb 0%, #ebedee 100%);
  --surface: rgba(255, 255, 255, 0.65);
  --surface2: rgba(255, 255, 255, 0.85);
  --border: rgba(255, 255, 255, 0.4);
  
  --text: #1d1d1f; 
  --text-muted: #86868b; 
  --sidebar-text: #475569;
  
  --primary: #0071e3; 
  --primary-h: #0077ed;
  --primary-light: rgba(0, 113, 227, 0.15);
  
  --success: #34c759; 
  --success-h: #2ecc71;
  --warn: #ff9f0a; 
  --error: #ff3b30;
  
  --shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.05);
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.15);
  
  --radius: 12px;
  --radius-lg: 16px;
  --glass-blur: blur(16px);
}

[data-theme="dark"] {
  --bg-gradient: linear-gradient(135deg, #1c1c1e 0%, #000000 100%);
  --surface: rgba(44, 44, 46, 0.55);
  --surface2: rgba(58, 58, 60, 0.75);
  --border: rgba(255, 255, 255, 0.1);
  
  --text: #f5f5f7; 
  --text-muted: #98989d; 
  --sidebar-text: #cbd5e1;
  
  --primary: #0a84ff; 
  --primary-h: #409cff;
  --primary-light: rgba(10, 132, 255, 0.15);
  
  --success: #32d74b; 
  --success-h: #34d399;
  --warn: #ffd60a; 
  --error: #ff453a;
  
  --shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.2);
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.5);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Satoshi', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg-gradient);
    background-attachment: fixed;
    color: var(--text);
    height: 100vh;
    overflow: hidden;
}

/* ===========================
   LAYOUT
   =========================== */
.app-container { display: flex; height: 100vh; }

.sidebar {
    width: 280px;
    background: var(--surface);
    display: flex;
    flex-direction: column;
    padding: 24px 16px;
    box-shadow: 2px 0 16px rgba(0,0,0,0.06);
    border-right: 1px solid var(--border);
    flex-shrink: 0;
    overflow-y: auto;
    z-index: 10;
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
}

.brand {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 12px 24px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 24px;
}

.brand-logo-text h2 {
    color: var(--text);
    font-size: 22px;
    font-weight: 800;
    display: flex;
    align-items: center;
    gap: 8px;
    letter-spacing: -0.5px;
}

.brand-logo-text p {
    color: var(--text-muted);
    font-size: 13px;
    margin-top: 4px;
    font-weight: 500;
}

.nav-links {
    list-style: none;
    margin-bottom: 24px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-links li {
    padding: 12px 16px;
    cursor: pointer;
    color: var(--sidebar-text);
    font-weight: 600;
    font-size: 15px;
    transition: all 0.2s ease;
    border-radius: 10px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.nav-links li i {
    font-size: 20px;
}

.nav-section-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.5px;
    margin: 12px 0 4px 12px;
}

.mt-4 { margin-top: 16px !important; }

.nav-links li:hover { 
    background: var(--surface2); 
    color: var(--text); 
}
.nav-links li.active { 
    background: var(--primary-light); 
    color: var(--primary); 
}

.nav-divider {
    height: 1px;
    background: var(--border);
    margin: 12px 0;
}

.nav-links li.nav-special {
    background: var(--primary);
    color: white;
}

.nav-links li.nav-special:hover {
    background: var(--primary-h);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.sidebar-kelas { padding: 8px 12px; }
.sidebar-label { color: var(--text-muted); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 12px; }

.kelas-buttons { display: flex; flex-direction: column; gap: 6px; }
.kelas-btn {
    background: transparent;
    border: 1px solid transparent;
    color: var(--sidebar-text);
    padding: 10px 14px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    text-align: left;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
}
.kelas-btn::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--border);
    display: inline-block;
}
.kelas-btn:hover { background: var(--surface2); color: var(--text); }
.kelas-btn.active { background: var(--surface2); color: var(--primary); border-color: var(--border); font-weight: 700; }
.kelas-btn.active::before { background: var(--primary); }

.sidebar-footer { margin-top: 12px; padding: 12px 0 0 0; display: flex; flex-direction: column; gap: 8px; border-top: 1px solid rgba(148, 163, 184, 0.25); }
.sidebar-footer-row { display:flex; gap:8px; margin-top:8px; }

.data-sync-status { display:flex; align-items:center; gap:8px; padding: 10px 12px; border-radius: 12px; font-size: 0.9rem; user-select: none; }
.data-sync-status i { font-size: 1.1rem; }
.data-sync-status.status-idle { background: rgba(148, 163, 184, 0.12); color: var(--muted); }
.data-sync-status.status-dirty { background: rgba(245, 158, 11, 0.12); color: #b45309; }
.data-sync-status.status-syncing { background: rgba(0, 113, 227, 0.12); color: var(--primary); }
.data-sync-status.status-synced { background: rgba(16, 185, 129, 0.12); color: #047857; }
.data-sync-status.status-error { background: rgba(239, 68, 68, 0.12); color: var(--error); }

.content {
    flex: 1;
    overflow-y: auto;
    padding: 40px;
    background: transparent;
}

.page-section { display: none; }
.page-section.active { display: block; animation: fadeIn 0.3s ease; }

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

/* ===========================
   PAGE HEADER & SETUP
   =========================== */
.page-header { margin-bottom: 32px; }
.page-title { font-size: 28px; font-weight: 800; color: var(--text); margin-bottom: 8px; display: flex; align-items: center; gap: 12px; letter-spacing: -0.5px; }
.page-title i { color: var(--primary); font-size: 32px; }
.page-desc { color: var(--text-muted); font-size: 15px; max-width: 600px; line-height: 1.5; }

/* Upload Grid */
.upload-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin-bottom: 32px;
}

.upload-card {
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-sm);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.upload-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow);
    background: var(--surface2);
}

.upload-card-header {
    display: flex;
    align-items: center;
    gap: 16px;
}

.upload-icon-wrapper {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

.upload-icon-wrapper.excel { background: #dcfce7; color: #16a34a; }
.upload-icon-wrapper.word { background: #e0f2fe; color: #0284c7; }

.upload-card h3 { font-size: 16px; font-weight: 700; color: var(--text); margin-bottom: 4px; }
.upload-card p { font-size: 13px; color: var(--text-muted); }

.upload-action { margin-top: auto; }

.tingkat-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    flex-wrap: wrap;
    background: var(--surface2);
    padding: 6px;
    border-radius: 12px;
    width: fit-content;
}

.tingkat-btn {
    padding: 8px 24px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-muted);
    background: transparent;
    border: none;
    transition: all 0.2s ease;
}

.tingkat-btn:hover:not(.active) { color: var(--text); }
.tingkat-btn.active {
    background: var(--surface);
    color: var(--primary);
    box-shadow: var(--shadow-sm);
}

.setup-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.tab-btn {
    padding: 8px 16px;
    border: 1px solid var(--border);
    background: var(--surface);
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    color: var(--text-muted);
    transition: all 0.2s ease;
}

.tab-btn:hover:not(.active) { color: var(--text); background: var(--surface2); border-color: var(--border); }
.tab-btn.active {
    background: var(--primary-light);
    color: var(--primary);
    border-color: var(--primary);
}
.tab-btn.saved::after { content: ' ✓'; color: var(--success); }
.tab-btn.active.saved::after { color: var(--success); }

.setup-form, .glass-panel {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
}

.form-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.form-header h2 { font-size: 18px; font-weight: 700; color: var(--text); }

.form-actions-top { display: flex; gap: 8px; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 0; }
.form-group { margin-bottom: 20px; }
.form-group.full-width { grid-column: 1 / -1; }

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.form-group input, .form-group select, .form-group textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    background: var(--surface);
    color: var(--text);
    outline: none;
    transition: all 0.2s;
    box-shadow: var(--shadow-sm);
}

.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.form-group input.is-invalid, .form-group select.is-invalid {
    border-color: var(--error);
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15);
    animation: shake 0.4s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-4px); }
    75% { transform: translateX(4px); }
}

.error-msg {
    font-size: 12px;
    color: var(--error);
    margin-top: 4px;
    display: none;
}
.is-invalid + .error-msg { display: block; }

/* Form Utilities */
.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    background: var(--surface);
    color: var(--text);
    outline: none;
    transition: all 0.2s;
}
.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }

.grid-3 { grid-template-columns: 1fr 1fr 1fr; }
.mb-0 { margin-bottom: 0 !important; }
.mb-3 { margin-bottom: 12px !important; }
.gap-lg { gap: 40px !important; }

.filter-panel {
    margin-bottom: 24px;
    padding: 16px;
}

/* ===========================
   STUDENT LIST
   =========================== */
.siswa-section { margin-top: 16px; }

.siswa-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.siswa-header-title { display: flex; align-items: center; gap: 12px; }
.icon-box { background: var(--primary-light); color: var(--primary); padding: 8px; border-radius: 8px; font-size: 18px; display: flex; }
.siswa-header h3 { font-size: 16px; font-weight: 700; color: var(--text); }

.siswa-actions { display: flex; gap: 8px; }

.siswa-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 12px;
    max-height: 500px;
    overflow-y: auto;
    padding-right: 8px;
}

.siswa-item {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 16px;
    transition: all 0.2s ease;
}

.siswa-item:hover { border-color: var(--primary-light); background: var(--surface2); }

.siswa-no {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    min-width: 24px;
    text-align: center;
}

.siswa-item input {
    flex: 1;
    border: 1px solid transparent;
    padding: 6px 12px;
    font-size: 14px;
    outline: none;
    background: transparent;
    font-weight: 500;
    color: var(--text);
    border-radius: 6px;
    transition: border-color 0.2s;
    box-shadow: none;
}
.siswa-item input:focus { border-color: var(--border); background: var(--surface); }

.btn-del-siswa {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 18px;
    padding: 4px;
    border-radius: 6px;
    transition: all 0.2s;
}
.btn-del-siswa:hover { color: var(--error); background: rgba(239, 68, 68, 0.1); }
.btn-del-siswa:focus-visible { outline: 2px solid var(--error); outline-offset: 2px; }

/* Theme Button */
.theme-btn {
    background: var(--surface2); border: 1px solid var(--border); border-radius: 50%; width: 36px; height: 36px;
    display: flex; align-items: center; justify-content: center; transition: all 0.3s ease; flex-shrink: 0; color: var(--text);
    cursor: pointer; font-size: 18px;
}
.theme-btn:hover { background: var(--border); }
.theme-btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* Buttons */
.btn-primary, .btn-print, .btn-add, .btn-secondary, .btn-ghost, .btn-success, .btn-success-dark, .btn-warning {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}
.btn-primary:focus-visible, .btn-secondary:focus-visible, .btn-ghost:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-full { width: 100%; }

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, #0056b3 100%); 
    color: white;
    box-shadow: 0 4px 12px rgba(0,113,227,0.3);
    border: none;
}
.btn-primary:hover { 
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 8px 24px rgba(0,113,227,0.4);
    filter: brightness(1.1);
}
.btn-primary:active { 
    transform: translateY(0) scale(0.96); 
}
.btn-primary:disabled { opacity: 0.7; cursor: not-allowed; transform: none; box-shadow: none; filter: none; }

.btn-print { background: var(--primary); color: white; }
.btn-print:hover { background: var(--primary-h); }

.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: var(--success-h); }
.btn-success:disabled { opacity: 0.7; cursor: not-allowed; }

.btn-success-dark { background: #059669; color: white; }
.btn-success-dark:hover { background: #047857; }

.btn-warning { background: var(--warn); color: white; }
.btn-warning:hover { background: #d97706; }

.btn-secondary {
    background: var(--surface);
    color: var(--text);
    border-color: var(--border);
    box-shadow: var(--shadow-sm);
}
.btn-secondary:hover { background: var(--surface2); }

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
}
.btn-ghost:hover { background: var(--surface2); color: var(--text); }

.btn-add { background: var(--primary); color: white; }
.btn-add:hover { background: var(--primary-h); }

.form-save {
    position: sticky;
    bottom: -24px;
    margin-top: 24px;
    margin-left: -24px;
    margin-right: -24px;
    margin-bottom: -24px;
    padding: 16px 24px;
    display: flex;
    align-items: center;
    gap: 16px;
    background: var(--surface2);
    border-top: 1px solid var(--border);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
    box-shadow: 0 -4px 24px rgba(0,0,0,0.06);
    z-index: 10;
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
}

.save-status { font-size: 14px; font-weight: 600; color: var(--success); }

/* ===========================
   MODAL
   =========================== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 24px;
    width: 500px;
    max-width: 90vw;
    box-shadow: 0 20px 40px rgba(0,0,0,0.2);
    border: 1px solid var(--border);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
}

.confirm-modal {
    width: 400px;
    text-align: center;
}
.confirm-icon {
    font-size: 48px;
    margin-bottom: 16px;
}
.text-error { color: var(--error); }

.modal h3 { font-size: 18px; font-weight: 700; margin-bottom: 8px; color: var(--text); }
.modal p { color: var(--text-muted); font-size: 14px; margin-bottom: 16px; }
.modal textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    resize: vertical;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    outline: none;
    background: var(--surface);
    color: var(--text);
}
.modal textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
.modal-actions { display: flex; justify-content: flex-end; gap: 12px; margin-top: 20px; }
.confirm-modal .modal-actions { justify-content: center; }

/* ===========================
   TOAST NOTIFICATION & EMPTY STATE
   =========================== */
#toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.toast {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--surface);
    color: var(--text);
    padding: 14px 20px;
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    border-left: 4px solid var(--primary);
    transform: translateX(120%);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    font-size: 14px;
    font-weight: 600;
}

.toast.show { transform: translateX(0); }
.toast-success { border-color: var(--success); }
.toast-success i { color: var(--success); }
.toast-error { border-color: var(--error); }
.toast-error i { color: var(--error); }

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 24px;
    text-align: center;
    color: var(--text-muted);
}
.empty-state i { font-size: 48px; color: var(--border); margin-bottom: 16px; }
.empty-state p { font-size: 16px; font-weight: 600; color: var(--text); margin-bottom: 4px; }
.empty-state .empty-desc { font-size: 13px; max-width: 300px; line-height: 1.5; }

/* Spinner Utilities */
.ph-spin {
    animation: spin 1s linear infinite;
}
@keyframes spin { 100% { transform: rotate(360deg); } }

/* ===========================
   PREVIEW PAGE
   =========================== */
.preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 16px;
}

.preview-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.action-menu { position: relative; }
.action-menu-trigger { display: inline-flex; align-items: center; gap: 6px; }
.action-menu-content {
    display: none;
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    min-width: 220px;
    padding: 6px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow);
    z-index: 30;
}
.action-menu:hover .action-menu-content,
.action-menu:focus-within .action-menu-content { display: grid; gap: 4px; }
.action-menu-content button {
    width: 100%;
    border: 0;
    background: transparent;
    color: var(--text);
    text-align: left;
    padding: 10px 12px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
}
.action-menu-content button:hover,
.action-menu-content button:focus-visible { background: var(--surface2); outline: none; }

#preview-container,
#preview-nilai-container,
#preview-sampul-container,
#preview-jurnal-container {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-sm);
    overflow-x: auto;
}

.preview-document-container {
    background: #fff !important;
    padding: 40px !important;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    min-height: 500px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow-x: auto;
}

/* ===========================
   ATTENDANCE TABLE (Screen)
   =========================== */
.attendance-page {
    font-family: Arial, sans-serif;
    font-size: 11px;
    color: #000;
    margin-bottom: 40px;
}

.attendance-page + .attendance-page {
    padding-top: 24px;
}

.att-header-title {
    text-align: center;
    font-size: 14px;
    font-weight: bold;
    letter-spacing: 0.5px;
    padding: 4px 0;
    background: #fff;
}

.att-header-tahun {
    text-align: center;
    font-size: 12px;
    font-weight: bold;
    padding: 3px 0;
    background: #fff;
}

.att-wali {
    padding: 4px 8px;
    font-size: 11px;
    font-weight: bold;
    background: #fff;
    margin-bottom: 8px;
}

.att-table {
    width: 100%;
    border-collapse: collapse;
    border: 1px solid #000;
}

.att-table th, .att-table td {
    border: 1px solid #000;
    text-align: center;
    padding: 2px 1px;
    font-size: 9px;
    vertical-align: middle;
    line-height: 1.2;
}

.att-table .col-no { width: 22px; }
.att-table .col-nama { width: 150px; text-align: left; padding-left: 5px; }
.att-table .col-pertemuan { width: 18px; font-size: 8px; }
.att-table .col-sig { width: 20px; font-size: 8px; }

.att-table thead tr:first-child th { background: #dce6f1; font-size: 10px; font-weight: bold; }
.att-table thead tr:nth-child(2) th { background: #dce6f1; font-size: 8px; }
.att-table thead tr:nth-child(3) th { background: #dce6f1; font-size: 8px; }
.att-table thead tr:nth-child(4) th { background: #fff; font-size: 8px; }

.att-table tbody tr td.col-nama { font-size: 10px; font-weight: 500; }
.att-table tbody tr:nth-child(even) td { background: #f5f8ff; }
.att-table tbody tr:nth-child(odd) td { background: #fff; }

/* ===========================
   PRINT STYLES
   =========================== */
@media print {
    /* @page diset secara dinamis via JavaScript (Portrait/Landscape) */

    html, body {
        height: auto !important;
        overflow: visible !important;
        width: 100% !important;
        background: #fff !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    body > *:not(#print-area) {
        display: none !important;
    }

    #print-area {
        display: block !important;
        position: static !important;
        width: 100%;
    }

    .print-page {
        margin: 0 !important;
        box-shadow: none !important;
        background: #fff !important;
        page-break-after: always;
        break-after: page;
        page-break-inside: avoid;
        break-inside: avoid;
    }

    .print-page:last-child {
        page-break-after: avoid;
        break-after: auto;
    }

    .att-header-title { font-size: 12pt !important; }
    .att-header-tahun { font-size: 10pt !important; }
    .att-wali { font-size: 9pt !important; }
    .att-table th, .att-table td { font-size: 6.5pt !important; padding: 1px !important; }
    .att-table .col-nama { font-size: 7.5pt !important; width: 130px !important; }
    .att-table .col-no { width: 18px !important; }
    .att-table .col-pertemuan { width: 14px !important; }
    .att-table .col-sig { width: 16px !important; }

    .nilai-table th, .nilai-table td { font-size: 7.5pt !important; padding: 2px !important; }
    .nilai-table .col-nama { font-size: 8pt !important; width: 140px !important; }
    .nilai-table tbody tr td { height: 22px !important; }
}

/* ===========================
   NILAI TABLE (Screen)
   =========================== */
.nilai-table {
    width: 100%;
    border-collapse: collapse;
    border: 1px solid #000;
}

.nilai-table th, .nilai-table td {
    border: 1px solid #000;
    text-align: center;
    padding: 2px 1px;
    font-size: 9px;
    vertical-align: middle;
}

.nilai-table .col-no { width: 22px; }
.nilai-table .col-nama { width: 150px; text-align: left; padding-left: 5px; }

.nilai-table thead tr:first-child th { background: #fff; font-size: 10px; font-weight: bold; }
.nilai-table thead tr:nth-child(2) th { background: #fff; font-size: 8px; }

.nilai-table tbody tr td.col-nama { font-size: 10px; font-weight: 500; }
.nilai-table tbody tr td { height: 18px; }

/* ===========================
   RESPONSIVE (MOBILE/TABLET)
   =========================== */
@media (max-width: 768px) {
    .app-container {
        flex-direction: column;
        height: auto;
        min-height: 100vh;
        overflow-y: auto;
    }
    body {
        overflow-y: auto;
    }
    .sidebar {
        width: 100%;
        height: auto;
        border-right: none;
        border-bottom: 1px solid var(--border);
        padding: 12px 10px;
        z-index: 1;
        gap: 10px;
    }
    .brand {
        margin-bottom: 10px;
        padding: 0 8px 12px;
    }
    .brand-logo-text h2 { font-size: 18px; }
    .brand-logo-text p { font-size: 12px; }
    .content {
        padding: 14px 12px;
        overflow-y: visible;
    }
    .form-row, .form-row[style*="grid-template-columns: 1fr 1fr 1fr;"] {
        grid-template-columns: 1fr !important;
    }
    .upload-grid {
        grid-template-columns: 1fr !important;
    }
    .nav-links {
        display: flex;
        flex-direction: row;
        flex-wrap: nowrap;
        gap: 8px;
        overflow-x: auto;
        padding-bottom: 4px;
        margin-bottom: 8px;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    .nav-links::-webkit-scrollbar { display: none; }
    .nav-section-title, .nav-special, .nav-divider { display: none !important; }
    .nav-links li {
        margin: 0;
        font-size: 13px;
        padding: 9px 12px;
        flex: 0 0 auto;
        justify-content: center;
        min-height: 40px;
        border: 1px solid var(--border);
        background: var(--surface2);
    }
    .nav-divider { display: none; }
    .preview-header {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
        margin-bottom: 16px;
    }
    .page-header { margin-bottom: 18px; }
    .page-title { font-size: 22px; line-height: 1.2; }
    .page-title i { font-size: 24px; }
    .page-desc { font-size: 13px; }
    .upload-grid { gap: 12px; margin-bottom: 18px; }
    .upload-card { padding: 16px; border-radius: 16px; gap: 12px; }
    .upload-card-header { gap: 12px; align-items: flex-start; }
    .upload-icon-wrapper { width: 42px; height: 42px; font-size: 21px; }
    .tingkat-tabs { width: 100%; display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 12px; }
    .tingkat-btn { padding: 9px 8px; font-size: 13px; }
    .setup-tabs { display: flex; overflow-x: auto; flex-wrap: nowrap; gap: 6px; padding-bottom: 4px; margin-bottom: 0; }
    .tab-btn { flex: 0 0 auto; min-height: 38px; padding: 8px 14px; }
    .setup-form, .glass-panel { padding: 16px; border-radius: 16px; }
    .form-header { align-items: flex-start; flex-direction: column; gap: 10px; margin-bottom: 16px; padding-bottom: 12px; }
    .form-actions-top, .siswa-actions { width: 100%; display: grid; grid-template-columns: 1fr; gap: 8px; }
    .form-actions-top button, .siswa-actions button { width: 100%; min-height: 40px; }
    .siswa-header { align-items: flex-start; flex-direction: column; gap: 10px; }
    .siswa-list { grid-template-columns: 1fr; max-height: none; padding-right: 0; gap: 8px; }
    .siswa-item { padding: 8px 10px; border-radius: 12px; }
    .form-save { position: static; margin: 16px -16px -16px; padding: 12px 16px; flex-direction: column; align-items: stretch; gap: 8px; }
    .form-save .btn-primary { width: 100%; min-height: 42px; }
    .preview-actions {
        flex-direction: column;
        width: 100%;
    }
    .preview-actions > * {
        width: 100%;
    }
    .preview-actions button,
    .action-menu-trigger {
        width: 100%;
    }
    .action-menu-content {
        position: static;
        display: grid;
        margin-top: 6px;
        min-width: 0;
    }
    .action-menu:not(:hover):not(:focus-within) .action-menu-content {
        display: none;
    }
    .modal {
        width: 95vw;
        padding: 16px;
    }
    #preview-container, #preview-nilai-container, #preview-sampul-container, #preview-jurnal-container {
        padding: 16px;
    }
    .attendance-page, .sampul-page, .print-page {
        /* Keep original dimensions so the paper looks like paper, user can scroll horizontally */
        margin: 0 auto 20px auto !important;
    }
    .att-table, .nilai-table {
        /* No need to force min-width if the container stays A4 width */
    }
    div[style*="display: grid; grid-template-columns: 1fr 1fr;"] {
        grid-template-columns: 1fr !important;
    }
}

.mobile-action-bar{
    display:none;
    position:fixed;
    left:10px;
    right:10px;
    bottom:calc(10px + env(safe-area-inset-bottom));
    z-index:1200;
    gap:8px;
    padding:8px;
    border:1px solid var(--border);
    border-radius:18px;
    background:rgba(255,255,255,.9);
    box-shadow:0 12px 34px rgba(0,0,0,.2);
    backdrop-filter:blur(18px);
}
[data-theme="dark"] .mobile-action-bar{ background:rgba(15,23,42,.9); }
.mobile-action-bar button{
    flex:1;
    border:0;
    border-radius:12px;
    padding:9px 7px;
    background:var(--surface2);
    color:var(--text);
    font-size:.76rem;
    font-weight:800;
}
.mobile-action-bar button:first-child{ background:var(--primary); color:white; }
@media (max-width:768px){
    body{ padding-bottom:146px; }
    .mobile-action-bar{ display:flex; bottom:calc(76px + env(safe-area-inset-bottom)); }
    #toast-container{ bottom:150px; }
}

.mobile-bottom-nav{
    display:none;
    position:fixed;
    left:10px;
    right:10px;
    bottom:calc(8px + env(safe-area-inset-bottom));
    z-index:1199;
    padding:7px;
    gap:4px;
    border:1px solid var(--border);
    border-radius:22px;
    background:rgba(255,255,255,.9);
    box-shadow:0 14px 34px rgba(0,0,0,.2);
    backdrop-filter:blur(18px);
}
[data-theme="dark"] .mobile-bottom-nav{ background:rgba(15,23,42,.9); }
.mbn-item{
    flex:1;
    display:flex;
    flex-direction:column;
    align-items:center;
    gap:3px;
    border:0;
    border-radius:16px;
    padding:7px 4px;
    background:transparent;
    color:var(--muted);
    font-size:.68rem;
    font-weight:800;
}
.mbn-item i{ font-size:20px; }
.mbn-item.active{ background:rgba(0,113,227,.11); color:var(--primary); }
@media (max-width:768px){ .mobile-bottom-nav{ display:flex; } }

/* =============================================
   GLOBAL SEARCH — STYLE
   ============================================= */
.global-search-wrap {
    position: relative;
    width: 100%;
}
.global-search-box {
    position: relative;
    display: flex;
    align-items: center;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0 12px;
    height: 38px;
    transition: all 0.2s cubic-bezier(0.34,1.56,0.64,1);
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.02);
}
.global-search-wrap.active .global-search-box {
    background: var(--surface);
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0,113,227,0.15);
}
.global-search-box svg {
    color: var(--muted);
    margin-right: 8px;
    flex-shrink: 0;
    transition: color 0.2s;
}
.global-search-wrap.active .global-search-box svg {
    color: var(--primary);
}
.global-search-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text);
    font-size: 0.88rem;
    font-weight: 500;
    width: 100%;
    padding: 0;
}
.global-search-input::placeholder {
    color: var(--text-muted);
}
.global-search-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    width: 100%;
    min-width: 280px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: 0 12px 36px rgba(0,0,0,0.18);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transform: translateY(-8px) scale(0.98);
    transition: all 0.2s cubic-bezier(0.34,1.56,0.64,1);
    max-height: 400px;
    overflow-y: auto;
    padding: 6px;
}
.global-search-dropdown.show {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0) scale(1);
}
.search-empty {
    padding: 16px;
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 500;
}
.search-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 10px 12px;
    background: transparent;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    text-align: left;
    transition: all 0.15s;
    gap: 12px;
}
.search-item:hover {
    background: var(--surface2);
}
.search-item:active {
    transform: scale(0.98);
}
.search-item-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow: hidden;
}
.search-item-name {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.search-item-meta {
    display: flex;
    align-items: center;
    gap: 8px;
}
.search-item-kelas {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--primary);
    background: rgba(0,113,227,0.1);
    padding: 2px 6px;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    gap: 3px;
}
.search-item-nisn {
    font-size: 0.72rem;
    color: var(--text-muted);
    font-family: monospace;
}
mark.hl {
    background: rgba(255,204,0,0.45);
    color: inherit;
    border-radius: 2px;
    padding: 0 1px;
    font-weight: inherit;
}
[data-theme="dark"] mark.hl {
    background: rgba(255,204,0,0.3);
}

/* ===========================
   JSPREADSHEET DARK MODE
   =========================== */
[data-theme="dark"] .jexcel_container {
    background: transparent;
}
[data-theme="dark"] .jexcel > thead > tr > td {
    background-color: var(--surface2) !important;
    color: var(--text);
    border-color: var(--border) !important;
}
[data-theme="dark"] .jexcel > tbody > tr > td {
    background-color: var(--surface) !important;
    color: var(--text);
    border-color: var(--border) !important;
}
[data-theme="dark"] .jexcel > tbody > tr > td.readonly {
    background-color: rgba(255, 255, 255, 0.03) !important;
    color: var(--text-muted);
}
[data-theme="dark"] .jexcel > tbody > tr > td.jexcel_cursor {
    border: 2px solid var(--primary) !important;
}
[data-theme="dark"] .jexcel > tbody > tr:hover > td {
    background-color: rgba(255, 255, 255, 0.05) !important;
}
