:root {
    --primary: #4F46E5;
    --primary-hover: #4338CA;
    --bg-color: #0f172a;
    --card-bg: rgba(255, 255, 255, 0.05);
    --card-border: rgba(255, 255, 255, 0.1);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;
    --sidebar-width: 250px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-main);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

/* Background Shapes for Glassmorphism Effect */
.bg-shape {
    position: fixed;
    border-radius: 50%;
    filter: blur(80px);
    z-index: -1;
    animation: float 10s infinite ease-in-out alternate;
}
.shape-1 { width: 300px; height: 300px; background: rgba(79, 70, 229, 0.4); top: -10%; left: -10%; }
.shape-2 { width: 400px; height: 400px; background: rgba(236, 72, 153, 0.3); bottom: -20%; right: -10%; animation-delay: -5s; }
.shape-3 { width: 250px; height: 250px; background: rgba(16, 185, 129, 0.2); top: 40%; left: 40%; animation-delay: -2s; }

@keyframes float {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(30px, -30px) scale(1.1); }
}

/* General Layout */
.view-section {
    display: none;
    min-height: 100vh;
}
.view-section.active {
    display: flex;
}

/* Glassmorphism Classes */
.glass-card {
    background: var(--card-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

/* ================= LOGIN VIEW ================= */
#view-login {
    justify-content: center;
    align-items: center;
    padding: 20px;
}
.login-container {
    width: 100%;
    max-width: 400px;
    padding: 40px 30px;
}
.login-container .header { text-align: center; margin-bottom: 30px; }
.login-container .header h1 { font-size: 2.2rem; }
.login-container .header h1 span { color: var(--primary); }
.login-hint { text-align: center; margin-top: 15px; color: var(--text-muted); font-size: 0.85rem; }

/* Connection Status Badge */
.connection-status {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
    margin-top: 15px;
    transition: all 0.3s ease;
}
.connection-status .status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.connection-status.checking {
    background: rgba(245, 158, 11, 0.15);
    color: #fbbf24;
    border: 1px solid rgba(245, 158, 11, 0.3);
}
.connection-status.checking .status-dot {
    background: #fbbf24;
    box-shadow: 0 0 8px #fbbf24;
    animation: pulse 1.2s infinite;
}

.connection-status.connected {
    background: rgba(16, 185, 129, 0.15);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.3);
}
.connection-status.connected .status-dot {
    background: #34d399;
    box-shadow: 0 0 8px #34d399;
}

.connection-status.disconnected {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.3);
}
.connection-status.disconnected .status-dot {
    background: #f87171;
    box-shadow: 0 0 8px #f87171;
}

@keyframes pulse {
    0% { opacity: 0.4; }
    50% { opacity: 1; }
    100% { opacity: 0.4; }
}

/* ================= MAIN APP VIEW ================= */
#view-app {
    flex-direction: row;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    position: fixed;
    left: 0;
    top: 0;
    display: flex;
    flex-direction: column;
    border-radius: 0;
    border-right: 1px solid var(--card-border);
    border-top: none; border-bottom: none; border-left: none;
    z-index: 100;
}
.sidebar-brand { padding: 20px 15px; text-align: center; border-bottom: 1px solid var(--card-border); flex-shrink: 0; }
.sidebar-brand h2 span { color: var(--primary); }

.user-info { padding: 15px 20px; display: flex; align-items: center; gap: 12px; border-bottom: 1px solid var(--card-border); flex-shrink: 0; }
.user-info .avatar { font-size: 1.8rem; background: rgba(255,255,255,0.1); padding: 8px; border-radius: 50%; }
.user-info h3 { font-size: 0.98rem; margin-bottom: 3px; word-break: break-word; }
.badge { display: inline-block; background: var(--primary); font-size: 0.75rem; padding: 3px 8px; border-radius: 12px; font-weight: bold; }

.sidebar-nav {
    flex: 1;
    padding: 15px 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    overflow-y: auto;
}
.sidebar-nav::-webkit-scrollbar {
    width: 4px;
}
.sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 10px;
}

.nav-item {
    background: transparent;
    border: none; color: var(--text-muted); text-align: left;
    padding: 12px 14px; font-size: 0.9rem; border-radius: 10px; cursor: pointer;
    transition: 0.3s;
    display: flex; align-items: center; gap: 10px;
}
.nav-item:hover, .nav-item.active { background: rgba(255,255,255,0.1); color: var(--text-main); }
.sidebar-footer { padding: 15px 20px; border-top: 1px solid var(--card-border); flex-shrink: 0; background: rgba(15, 23, 42, 0.95); z-index: 101; }
.btn-logout { width: 100%; background: rgba(239, 68, 68, 0.2); color: var(--error); border: 1px solid rgba(239, 68, 68, 0.3); padding: 12px; border-radius: 10px; cursor: pointer; font-weight: bold; transition: 0.3s; }
.btn-logout:hover { background: var(--error); color: white; }

/* Main Content Area */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    padding: 30px;
    min-height: 100vh;
}
.panel { display: none; animation: fadeIn 0.4s ease forwards; }
.panel.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

.panel-header { margin-bottom: 25px; }
.panel-header h2 { font-size: 1.8rem; margin-bottom: 5px; }
.panel-header p { color: var(--text-muted); }
.flex-between { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 15px; }

/* ================= COMPONENTS ================= */

/* Forms & Inputs */
.form-container { display: flex; flex-direction: column; gap: 20px; }
.input-group { position: relative; }
.input-group input, .input-group select {
    width: 100%; background: rgba(0, 0, 0, 0.2); border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px; padding: 16px; color: var(--text-main); font-size: 1rem; outline: none; transition: 0.3s;
}
.input-group input:focus, .input-group select:focus { border-color: var(--primary); background: rgba(0, 0, 0, 0.4); }
.input-group label { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); color: var(--text-muted); transition: 0.3s; pointer-events: none; }
.input-group input:focus ~ label, .input-group input:not(:placeholder-shown) ~ label {
    top: -10px; left: 10px; font-size: 0.8rem; background: var(--bg-color); padding: 0 6px; color: var(--primary); border-radius: 4px;
}
.input-group .select-label { top: -10px; left: 10px; font-size: 0.8rem; background: var(--bg-color); padding: 0 6px; color: var(--text-muted); }
select option { background: var(--bg-color); color: var(--text-main); }

/* Buttons */
.btn-primary, .btn-secondary {
    border: none; border-radius: 12px; padding: 15px; font-size: 1rem; font-weight: 600; cursor: pointer; transition: 0.3s;
    display: flex; justify-content: center; align-items: center;
}
.btn-primary { background: linear-gradient(135deg, var(--primary), #a855f7); color: white; box-shadow: 0 10px 15px -3px rgba(79, 70, 229, 0.3); }
.btn-primary:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 15px 20px -5px rgba(79, 70, 229, 0.4); }
.btn-primary:disabled { opacity: 0.7; cursor: not-allowed; background: #475569; }
.btn-secondary { background: rgba(255,255,255,0.1); color: white; border: 1px solid rgba(255,255,255,0.2); }
.btn-secondary:hover { background: rgba(255,255,255,0.2); }

.loader { border: 3px solid rgba(255,255,255,0.3); border-radius: 50%; border-top: 3px solid white; width: 20px; height: 20px; animation: spin 1s linear infinite; }
@keyframes spin { 100% { transform: rotate(360deg); } }

/* Tabs (Scanner) */
.tabs { display: flex; background: rgba(0, 0, 0, 0.2); border-radius: 12px; padding: 5px; margin-bottom: 25px; }
.tab-btn { flex: 1; background: transparent; border: none; color: var(--text-muted); padding: 12px; font-weight: 600; border-radius: 8px; cursor: pointer; transition: 0.3s; }
.tab-btn.active { background: rgba(255, 255, 255, 0.1); color: var(--text-main); }
.tab-content { display: none; animation: fadeIn 0.4s; }
.tab-content.active { display: block; }
.panel-body { padding: 30px; }

/* Dashboard Specific */
.filter-group { display: flex; gap: 10px; padding: 10px 20px; border-radius: 12px; }
.filter-group select { background: rgba(0,0,0,0.3); color: white; border: 1px solid rgba(255,255,255,0.2); padding: 10px; border-radius: 8px; outline: none; }
.filter-group button { padding: 10px 20px; }

.stats-container { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 20px; margin-top: 20px; }
.stat-card { display: flex; align-items: center; gap: 15px; padding: 20px; }
.stat-icon { width: 50px; height: 50px; border-radius: 12px; display: flex; justify-content: center; align-items: center; font-size: 1.5rem; }
.bg-success-light { background: rgba(16, 185, 129, 0.1); border: 1px solid rgba(16, 185, 129, 0.2); }
.bg-warning-light { background: rgba(245, 158, 11, 0.1); border: 1px solid rgba(245, 158, 11, 0.2); }
.bg-primary-light { background: rgba(79, 70, 229, 0.1); border: 1px solid rgba(79, 70, 229, 0.2); }
.stat-info h3 { font-size: 0.9rem; color: var(--text-muted); font-weight: 400; }
.stat-value { font-size: 1.8rem; font-weight: 700; }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }

.data-table { width: 100%; border-collapse: collapse; min-width: 600px; }
.data-table th, .data-table td { padding: 12px 15px; text-align: left; border-bottom: 1px solid var(--card-border); }
.data-table th { color: var(--text-muted); font-weight: 500; }
.data-table tr:hover { background: rgba(255,255,255,0.02); }

/* Matrix Table Styling (Matching User Screenshot Layout) */
.matrix-table { min-width: 700px; border-collapse: collapse; margin-top: 10px; }
.matrix-table th, .matrix-table td { border: 1px solid var(--card-border); padding: 10px 12px; text-align: center; font-size: 0.9rem; }
.matrix-table th { background: rgba(255, 255, 255, 0.08); font-weight: 600; text-transform: uppercase; color: var(--text-main); }
.matrix-table tfoot td { background: rgba(255, 255, 255, 0.06); font-weight: bold; font-size: 0.95rem; }

/* QR Reader Overrides */
#reader { width: 100%; border-radius: 16px; overflow: hidden; background: rgba(0,0,0,0.3); border: 1px solid rgba(255,255,255,0.1); }
#reader button { background: var(--primary); color: white; border: none; padding: 8px 16px; border-radius: 8px; cursor: pointer; margin: 10px; font-family: 'Outfit'; }
#reader select { background: rgba(255,255,255,0.1); color: white; padding: 8px; border-radius: 8px; margin: 10px; outline: none; }
#reader select option { background: var(--bg-color); }
#reader a { display: none; }
#reader video { border-radius: 16px; width: 100%; }
.scan-instructions { text-align: center; margin-top: 15px; color: var(--text-muted); }

/* Toast */
.toast { position: fixed; bottom: -100px; left: 50%; transform: translateX(-50%); background: white; color: #333; padding: 14px 24px; border-radius: 12px; box-shadow: 0 10px 25px rgba(0,0,0,0.2); font-weight: 600; font-size: 0.95rem; transition: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55); z-index: 1000; width: max-content; max-width: 90vw; }
.toast.show { bottom: 30px; }
.toast.success { background: #065f46; color: #ecfdf5; border: 1px solid #10b981; }
.toast.error { background: #7f1d1d; color: #fef2f2; border: 1px solid #ef4444; }

/* Responsive */
@media (max-width: 768px) {
    #view-app { flex-direction: column; }
    .sidebar { width: 100%; height: auto; position: relative; border-right: none; border-bottom: 1px solid var(--card-border); }
    .main-content { margin-left: 0; padding: 15px; }
    .sidebar-nav { flex-direction: row; flex-wrap: wrap; justify-content: center; }
    .nav-item { flex: 1; text-align: center; justify-content: center; padding: 10px; }
    .nav-item .nav-icon { display: block; font-size: 1.2rem; margin-bottom: 5px; }
    .sidebar-footer { padding: 10px; }
}

/* Violation Badge Pills (Pills Warna-Warni Sesuai Gambar Contoh) */
.badge-pelanggaran { display: inline-block; padding: 4px 10px; border-radius: 12px; font-size: 0.76rem; font-weight: 600; text-align: center; white-space: nowrap; box-shadow: 0 2px 4px rgba(0,0,0,0.15); }
.badge-pelanggaran-terlambat { background: #b91c1c; color: #ffffff; }
.badge-pelanggaran-dasi { background: #991b1b; color: #fecaca; }
.badge-pelanggaran-pinggang { background: #78716c; color: #f5f5f4; }
.badge-pelanggaran-kacu { background: #ea580c; color: #ffedd5; }
.badge-pelanggaran-ring { background: #ca8a04; color: #fef9c3; }
.badge-pelanggaran-sepatu { background: #059669; color: #d1fae5; }
.badge-pelanggaran-atribut { background: #0284c7; color: #e0f2fe; }
.badge-pelanggaran-izin { background: #0d9488; color: #ccfbf1; }
.badge-pelanggaran-solek { background: #c026d3; color: #fae8ff; }
.badge-pelanggaran-bahasa { background: #6b21a8; color: #f3e8ff; }
.badge-pelanggaran-lainnya { background: #2563eb; color: #dbeafe; }

@media (max-width: 992px) {
    .pelanggaran-layout-grid { grid-template-columns: 1fr !important; }
}

/* Print Media Styles for Matrix & Pelanggaran Reports */
@media print {
    body { background: white !important; color: black !important; font-family: 'Times New Roman', Arial, sans-serif !important; }
    .sidebar, .panel-header, .sidebar-brand, .sidebar-footer, .glass-card:not(#printableReport):not(#printablePelanggaranReport), .toast, button, nav, #containerFormPelanggaran, #containerManageJenisModal { display: none !important; }
    #view-app { display: block !important; }
    .main-content { margin-left: 0 !important; padding: 0 !important; width: 100% !important; }
    .panel { display: block !important; padding: 0 !important; }
    #printableReport, #printablePelanggaranReport { background: transparent !important; border: none !important; box-shadow: none !important; padding: 0 !important; color: black !important; }
    #headerPelanggaranPrint { display: block !important; }
    .matrix-table, .pelanggaran-table { width: 100% !important; border-collapse: collapse !important; color: black !important; font-size: 8pt !important; }
    .matrix-table th, .matrix-table td, .pelanggaran-table th, .pelanggaran-table td { border: 1px solid black !important; color: black !important; background: transparent !important; }
    .matrix-table th, .pelanggaran-table th { font-weight: bold !important; background: #f0f0f0 !important; }
    .badge-pelanggaran { background: transparent !important; color: black !important; border: 1px solid #666 !important; font-weight: bold !important; padding: 1px 4px !important; }
    .matrix-report-header h2, .matrix-report-header h3, .matrix-report-header p { color: black !important; }
    @page { size: A4 landscape; margin: 8mm; }
}

/* ================= PRESET ELEGANT STYLES FOR TEACHER ABSENSI & IZIN ================= */
.styled-card {
    background: rgba(15, 23, 42, 0.75);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 16px;
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.styled-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 14px;
    margin-bottom: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.styled-card-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: #f8fafc;
    display: flex;
    align-items: center;
    gap: 10px;
}

.styled-form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.styled-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: #cbd5e1;
    display: flex;
    align-items: center;
    gap: 6px;
}

.styled-input, .styled-select, .styled-textarea {
    width: 100%;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #f8fafc;
    padding: 12px 16px;
    border-radius: 10px;
    font-size: 0.95rem;
    outline: none;
    transition: all 0.25s ease;
}

.styled-input:focus, .styled-select:focus, .styled-textarea:focus {
    border-color: #6366f1;
    background: rgba(15, 23, 42, 0.85);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.25);
}

.styled-input::placeholder, .styled-textarea::placeholder {
    color: #64748b;
}

/* Data Table Modern Styling */
.modern-table-container {
    overflow-x: auto;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(15, 23, 42, 0.4);
}

.data-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    min-width: 650px;
}

.data-table th {
    background: rgba(30, 41, 59, 0.85);
    color: #94a3b8;
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 14px 18px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.data-table td {
    padding: 14px 18px;
    font-size: 0.9rem;
    color: #e2e8f0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    vertical-align: middle;
}

.data-table tbody tr {
    transition: background 0.2s ease;
}

.data-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.04);
}

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

/* Status Badges */
.badge-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.3px;
}

.badge-pending {
    background: rgba(245, 158, 11, 0.15);
    color: #fbbf24;
    border: 1px solid rgba(245, 158, 11, 0.35);
}

.badge-approved {
    background: rgba(34, 197, 94, 0.15);
    color: #4ade80;
    border: 1px solid rgba(34, 197, 94, 0.35);
}

.badge-rejected {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.35);
}
