/* ==========================================================================
   SECTION 1: CSS LANDING PAGE UTAMA (PORTAL SIPELITA) - DIPERTAHANKAN ASLI
   ========================================================================== */
:root {
    --bg: #f4f6f9;
    --text: #2c3e50;
    --text-light: #7f8c8d;
    --card-radius: 14px;
    --shadow: 0 6px 16px rgba(0,0,0,0.08);
    --shadow-hover: 0 10px 24px rgba(0,0,0,0.15);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

body {
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    padding-bottom: 40px;
}

.container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 24px;
}

header {
    background: #ffffff;
    padding: 20px 24px;
    border-radius: var(--card-radius);
    box-shadow: var(--shadow);
    margin-bottom: 28px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
}

header h1 {
    font-size: 1.6rem;
    color: #1a237e;
    font-weight: 700;
}

header p {
    color: var(--text-light);
    font-size: 0.95rem;
    margin-top: 4px;
}

.badge {
    background: #e8f5e9;
    color: #2e7d32;
    padding: 8px 14px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
}

.section-title {
    font-size: 1.25rem;
    margin: 28px 0 16px;
    padding-left: 12px;
    border-left: 5px solid #1a237e;
    font-weight: 600;
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 18px;
    margin-bottom: 40px;
}

.card-link {
    text-decoration: none;
    color: inherit;
    display: block;
    cursor: pointer;
}

.card {
    background: #ffffff;
    padding: 22px 16px;
    border-radius: var(--card-radius);
    box-shadow: var(--shadow);
    transition: all 0.25s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 10px;
    position: relative;
    overflow: hidden;
    height: 100%;
}

.card-link:hover .card {
    transform: translateY(-5px);
    box-shadow: var(--shadow-hover);
}

.card-icon {
    font-size: 2.2rem;
    margin-bottom: 6px;
}

.card-logo {
    width: 56px;
    height: 56px;
    object-fit: contain;
    margin-bottom: 6px;
    border-radius: 12px;
}

.card-title {
    font-weight: 600;
    font-size: 1rem;
}

.card-desc {
    font-size: 0.82rem;
    opacity: 0.9;
}

.status-tag {
    font-size: 0.72rem;
    margin-top: 8px;
    padding: 4px 10px;
    border-radius: 12px;
    font-weight: 600;
    display: inline-block;
    background: rgba(255,255,255,0.2);
}

/* Modal Landing Page */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15,23,42,0.6);
    backdrop-filter: blur(4px);
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: #ffffff;
    padding: 28px;
    border-radius: var(--card-radius);
    width: 92%;
    max-width: 480px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.2);
    animation: slideUp 0.3s ease;
}

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

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.close-btn {
    background: none;
    border: none;
    font-size: 1.8rem;
    cursor: pointer;
    color: #64748b;
    line-height: 1;
}

.form-group {
    margin-bottom: 18px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    font-size: 0.9rem;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 12px;
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    font-size: 0.95rem;
    transition: border 0.2s;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: #1a237e;
}

.btn {
    background: #1a237e;
    color: white;
    border: none;
    padding: 12px;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    width: 100%;
    font-size: 0.95rem;
    transition: background 0.2s;
}

.btn:hover { background: #283593; }
.btn:disabled { background: #94a3b8; cursor: not-allowed; }

footer {
    text-align: center;
    margin-top: 48px;
    color: var(--text-light);
    font-size: 0.85rem;
}

.header-logo {
    height: 60px !important;
    width: auto;
    object-fit: contain;
}

/* ==========================================================================
   PERBAIKAN RESPONSIVE MOBILE (3 KOLOM PRESISI)
   ========================================================================== */
@media (max-width: 640px) {
    /* 1. Paksa 3 kolom, abaikan aturan minmax(220px) dari desktop */
    .grid {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 8px !important; /* Jarak antar card diperkecil */
        margin-bottom: 24px;
    }

    /* 2. Perkecil padding dan atur proporsi card agar tidak gepeng */
    .card {
        padding: 12px 6px !important; /* Padding sangat dikurangi */
        gap: 6px !important; /* Jarak antara ikon dan teks */
        min-height: 110px; /* Tinggi minimum agar tidak terlalu gepeng */
        aspect-ratio: 1 / 1.15; /* Menjaga rasio bentuk card tetap konsisten */
    }

    /* 3. Skala ulang Ikon agar proporsional dengan card kecil */
    .card-icon {
        font-size: 1.6rem !important; /* Turun dari 2.2rem */
        margin-bottom: 4px !important;
    }

    /* 4. Skala ulang Logo (jika ada) */
    .card-logo {
        width: 36px !important; /* Turun dari 56px */
        height: 36px !important;
        margin-bottom: 4px !important;
    }

    /* 5. Skala ulang Teks agar muat dan tidak berantakan */
    .card-title {
        font-size: 0.75rem !important; /* Turun dari 1rem */
        line-height: 1.2 !important;
        font-weight: 700;
    }

    .card-desc {
        font-size: 0.65rem !important; /* Turun dari 0.82rem */
        line-height: 1.2 !important;
        opacity: 0.85;
    }

    .status-tag {
        font-size: 0.6rem !important;
        padding: 2px 6px !important;
        margin-top: 4px !important;
    }

    /* --- Penyesuaian Elemen Lain di Mobile (Dipertahankan dari kode asli) --- */
    .container {
        padding: 16px;
    }
    
    .header-logo { 
        height: 25px !important; 
        width: auto; 
    }
    
    header { 
        flex-direction: column; 
        align-items: flex-start; 
        padding: 16px;
    }
    
    #userPanel { 
        display: flex; 
        align-items: center; 
        gap: 12px; 
    }
    
    #btnLogout:hover { 
        background: #d32f2f; 
        transform: translateY(-2px); 
        transition: 0.2s; 
    }
    
    #userRole { 
        animation: pulse 2s infinite; 
    }
    
    @keyframes pulse { 
        0%, 100% { opacity: 1; } 
        50% { opacity: 0.8; } 
    }
}

/* Tambahan: Untuk layar HP sangat kecil (misal: iPhone SE, Galaxy Fold tertutup) */
@media (max-width: 360px) {
    .grid {
        gap: 6px !important;
    }
    .card {
        padding: 10px 4px !important;
        min-height: 100px;
    }
    .card-icon {
        font-size: 1.4rem !important;
    }
    .card-title {
        font-size: 0.7rem !important;
    }
    .card-desc {
        font-size: 0.6rem !important;
    }
}

/* ==========================================================================
   SECTION 2: CSS KHUSUS MODUL SIPENA (MENGGUNAKAN SCOPED CLASS .sipena-modul)
   ========================================================================== */

/* Background khusus aplikasi SIPENA */
body.sipena-bg {
    background: linear-gradient(135deg, #115e59 0%, #047857 50%, #065f46 100%);
    min-height: 100vh;
}

.sipena-modul .main-container {
    padding: 20px;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

/* SIPENA Header */
.sipena-modul .sipena-header {
    background: white;
    padding: 20px;
    border-radius: 15px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 20px;
}

.sipena-modul .header-logo-sp {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid #667eea;
}

.sipena-modul .header-info-sp {
    flex: 1;
}

.sipena-modul .header-title-sp {
    font-size: 28px;
    font-weight: bold;
    color: #086d22;
    margin-bottom: 5px;
}

.sipena-modul .header-subtitle-sp {
    font-size: 14px;
    color: #333333;
}

.sipena-modul .logout-btn-sp {
    padding: 8px 20px;
    background: #e74c3c;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s;
}

.sipena-modul .logout-btn-sp:hover { background: #c0392b; }

/* SIPENA Menu Grid Dashboard */
.sipena-modul .menu-grid-sp {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 10px;
    margin-bottom: 20px;
}

.sipena-modul .menu-card-sp {
    background: rgb(255, 255, 255);
    padding: 20px 10px;
    border-radius: 10px;
    box-shadow: 0 3px 8px rgba(0,0,0,0.1);
    cursor: pointer;
    transition: all 0.3s;
    text-align: center;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 110px;
}

.sipena-modul .menu-card-sp:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 15px rgba(0,0,0,0.15);
}

.sipena-modul .menu-title-sp {
    font-size: 11px;
    font-weight: 600;
    color: #333;
    line-height: 1.2;
    margin-top: 6px;
}

/* SIPENA Konten Area */
.sipena-modul .content-area-sp {
    background: white;
    padding: 25px;
    border-radius: 15px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
    display: none;
}

.sipena-modul .content-area-sp.active {
    display: block;
}

.sipena-modul .section-title-sp {
    font-size: 24px;
    font-weight: bold;
    color: #333;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 3px solid #667eea;
}

.sipena-modul .date-display-sp {
    font-size: 18px;
    font-weight: bold;
    color: #e74c3c;
    margin-bottom: 15px;
    padding: 12px;
    background: #f8f9fa;
    border-radius: 8px;
    text-align: center;
}

/* SIPENA Form & Input */
.sipena-modul .form-group-sp {
    margin-bottom: 20px;
    text-align: left;
}

.sipena-modul .form-label-sp {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: #333333;
    margin-bottom: 8px;
}

.sipena-modul .form-input-sp {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    font-size: 14px;
    transition: all 0.3s;
}

.sipena-modul .form-input-sp:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102,126,234,0.1);
}

/* SIPENA Tombol & Tabs */
.sipena-modul .action-bar-sp {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.sipena-modul .btn-sp {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.sipena-modul .btn-sp-primary { background: #0a55f7; color: white; }
.sipena-modul .btn-sp-primary:hover { background: #3b74f3; }
.sipena-modul .btn-sp-success { background: #27ae60; color: white; }
.sipena-modul .btn-sp-success:hover { background: #219954; }
.sipena-modul .btn-sp-secondary { background: #a6a395; color: white; }

.sipena-modul .tabs-sp {
    display: flex;
    gap: 5px;
    margin-bottom: 20px;
    border-bottom: 2px solid #e0e0e0;
    overflow-x: auto;
}

.sipena-modul .tab-sp {
    padding: 12px 20px;
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    font-size: 14px;
    font-weight: 600;
    color: #666;
    cursor: pointer;
    transition: all 0.3s;
    white-space: nowrap;
}

.sipena-modul .tab-sp.active {
    color: #0a55f7;
    border-bottom-color: #0a55f7;
}

/* SIPENA Tables */
.sipena-modul .table-container-sp {
    overflow-x: auto;
    margin-top: 20px;
    background: white;
    border-radius: 8px;
}

.sipena-modul table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.sipena-modul th, .sipena-modul td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #e0e0e0;
}

.sipena-modul th {
    background: #f8f9fa;
    font-weight: 600;
    color: #333;
}

/* Responsif khusus SIPENA */
@media(max-width: 768px) {
    .sipena-modul .sipena-header { flex-direction: column; text-align: center; }
    .sipena-modul .menu-grid-sp { grid-template-columns: repeat(3, 1fr); gap: 8px; }
}

/* Container Utama Grid Galeri */
.galeri-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 25px;
    padding: 20px 0;
    max-width: 1200px;
    margin: 0 auto;
}

/* Kartu Utama Berbasis Glassmorphism */
.galeri-card {
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 16px;
    overflow: hidden;
    text-decoration: none;
    box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.07);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    flex-direction: column;
}

/* Efek Hover saat Kartu Disorot */
.galeri-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 12px 40px 0 rgba(31, 38, 135, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.5);
}

/* Pembungkus Gambar */
.card-image-wrapper {
    position: relative;
    width: 100%;
    height: 200px; /* Tinggi seragam untuk semua sampul */
    overflow: hidden;
    background-color: #f1f5f9;
}

/* Pengaturan Foto Sampul Asli */
.card-img {
    width: 100%;
    height: 100%;
    object-fit: cover; /* Memotong gambar secara proporsional agar pas di kotak */
    transition: transform 0.5s ease;
}

.galeri-card:hover .card-img {
    transform: scale(1.08); /* Efek zoom-in halus saat dihover */
}

.card-image-placeholder {
    width: 100%;
    height: 100%;
}

/* Area Judul Kegiatan */
.card-body {
    padding: 16px;
    background: rgba(255, 255, 255, 0.5);
    border-top: 1px solid rgba(255, 255, 255, 0.2);
    flex-grow: 1;
    display: flex;
    align-items: center;
}

.card-title {
    font-size: 1.05rem;
    color: #1e293b;
    font-weight: 600;
    margin: 0;
    line-height: 1.4;
    letter-spacing: 0.3px;
    transition: color 0.3s ease;
}

.galeri-card:hover .card-title {
    color: #4f46e5; /* Judul berubah warna ke ungu saat dihover */
}

/* ==========================================================================
   SECTION 3: CSS KHUSUS MODUL SCANNER & KARTU HASIL ABSENSI (SICAN MODERN)
   ========================================================================== */

/* Kontainer Utama Hasil Scan Berbasis Glassmorphism Lembut */
.scan-result-card {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: var(--card-radius);
    box-shadow: var(--shadow);
    padding: 26px;
    margin: 24px auto;
    max-width: 400px;
    text-align: center;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    animation: slideUpSican 0.4s ease forwards;
}

/* Efek Sorot saat Kartu Sukses Berhasil Ditampilkan */
.scan-result-card:hover {
    box-shadow: var(--shadow-hover);
    border-color: rgba(46, 125, 50, 0.4);
}

/* Badge "ABSENSI BERHASIL" yang Segar */
.card-badge {
    background-color: #e8f5e9;
    color: #2e7d32;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    margin-bottom: 18px;
    border: 1px solid rgba(46, 125, 50, 0.15);
}

.badge-icon {
    font-weight: 900;
}

/* Penataan Data Profil Siswa */
.student-name {
    color: var(--text);
    font-size: 1.4rem;
    font-weight: 700;
    margin: 0 0 6px 0;
    line-height: 1.3;
}

.student-class {
    color: var(--text-light);
    font-size: 0.9rem;
    font-weight: 600;
    margin: 0 0 16px 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Pembatas Garis Transparan Halus */
.scan-result-card .divider {
    height: 1px;
    background: linear-gradient(to right, rgba(0,0,0,0.01), rgba(0,0,0,0.08), rgba(0,0,0,0.01));
    margin: 18px 0;
}

/* Baris Detail Informasi Kegiatan */
.info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 18px;
    font-size: 0.9rem;
}

.info-label {
    color: var(--text-light);
    font-weight: 500;
}

.info-value {
    color: var(--text);
    font-weight: 600;
    background: rgba(255, 255, 255, 0.5);
    padding: 4px 10px;
    border-radius: 6px;
    border: 1px solid rgba(0, 0, 0, 0.04);
}

/* Indikator Penanda Jam Log Absensi Real-Time */
.time-badge {
    background: #1a237e;
    color: #ffffff;
    display: inline-block;
    padding: 8px 20px;
    border-radius: 10px;
    font-size: 1.1rem;
    font-weight: 700;
    font-family: monospace;
    letter-spacing: 1px;
    box-shadow: 0 4px 12px rgba(26, 35, 126, 0.2);
}

/* Animasi Muncul Halus Mengikuti Logika CSS Utama */
@keyframes slideUpSican {
    from {
        opacity: 0;
        transform: translateY(15px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Responsivitas untuk Layar Ponsel Pintar */
@media (max-width: 640px) {
    .scan-result-card {
        width: 95%;
        padding: 20px 16px;
        margin: 16px auto;
    }
    .student-name {
        font-size: 1.25rem;
    }
}

/* ==========================================================================
   SECTION 4: CSS KHUSUS MODUL PKKM (SISTEM KARTU MODERN E-DOKUMEN)
   ========================================================================== */

.pkkm-wrapper {
    background: #ffffff;
    padding: 28px;
    border-radius: 16px;
    box-shadow: 0 6px 16px rgba(0,0,0,0.06);
    margin-bottom: 30px;
}

/* Desain Kartu Grid Seperti E-Dokumen */
.pkkm-grid-dokumen {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 16px;
    margin-top: 15px;
}

.pkkm-card-box {
    background: #f8fafc;
    border-left: 4px solid #1a237e;
    border-radius: 12px;
    padding: 18px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.02);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: transform 0.2s, box-shadow 0.2s;
    border: 1px solid #e2e8f0;
    border-left: 4px solid #1a237e;
}

.pkkm-card-box:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 16px rgba(0,0,0,0.08);
}

.pkkm-card-meta {
    font-size: 0.8rem;
    color: #64748b;
    margin-top: 4px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.pkkm-card-action {
    display: flex;
    gap: 8px;
    margin-top: 16px;
    border-top: 1px dashed #e2e8f0;
    padding-top: 12px;
}

/* Tombol Aksi Mini */
.btn-action-mini {
    flex: 1;
    padding: 8px 10px;
    border: none;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    transition: background 0.2s;
}

.btn-mini-lihat { background: #e8f5e9; color: #2e7d32; }
.btn-mini-lihat:hover { background: #c8e6c9; }
.btn-mini-unduh { background: #e8eaf6; color: #1a237e; }
.btn-mini-unduh:hover { background: #c5cae9; }
.btn-mini-hapus { background: #ffebee; color: #c62828; }
.btn-mini-hapus:hover { background: #ffcdd2; }

/* Status Alert Kosong */
.status-empty-box {
    grid-column: 1 / -1;
    text-align: center;
    padding: 40px;
    color: #94a3b8;
    font-style: italic;
    background: #f8fafc;
    border-radius: 12px;
    border: 2px dashed #cbd5e1;
}
