
:root {
    --mcd-red: #DA291C;
    --mcd-yellow: #FFC72C;
    --mcd-black: #27251F;
    --bg-color: #fce8e6;
    --ios-radius: 18px;
}

/* --- BASIC RESET --- */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-color);
    margin: 0; padding: 20px;
    padding-top: max(20px, env(safe-area-inset-top));
    padding-bottom: max(20px, env(safe-area-inset-bottom));
    color: var(--mcd-black);
    min-height: 100vh;
}

/* --- UI UTAMA (SCREEN) --- */
#app-ui { 
    max-width: 600px; margin: 0 auto; padding-bottom: 50px; 
    position: relative; z-index: 1; 
    transition: filter 0.3s ease;
}

header {
    text-align: center; background-color: var(--mcd-red); color: white;
    padding: 25px; border-radius: var(--ios-radius); margin-bottom: 25px;
    box-shadow: 0 8px 20px rgba(218, 41, 28, 0.25); border-bottom: 5px solid var(--mcd-yellow);
}

#digital-clock {
    margin-top: 15px; font-size: 1.1rem; font-weight: 700; color: white;
    background: rgba(0,0,0,0.1); padding: 5px 15px; border-radius: 20px;
    display: inline-block; border: 1px solid var(--mcd-yellow);
}

#connection-status { font-size: 0.8rem; margin-top: 5px; color: rgba(255,255,255,0.8); }

/* BUTTONS */
.menu-btn, .btn {
    background: white; border: none; width: 100%; padding: 18px;
    border-radius: 12px; font-size: 1rem; font-weight: 700;
    color: var(--mcd-black); margin-bottom: 12px;
    display: flex; justify-content: space-between; align-items: center;
    box-shadow: 0 4px 10px rgba(0,0,0,0.05); cursor: pointer;
    transition: transform 0.1s; -webkit-appearance: none;
}
.menu-btn:active, .btn:active { transform: scale(0.98); background: #f5f5f5; }
.menu-btn { border-left: 8px solid var(--mcd-yellow); }
.summary-btn { border-left: 8px solid var(--mcd-red); background: #fff0f0; color: var(--mcd-red); }
.telegram-btn { background-color: #229ED9; color: white; justify-content: center; border: none; }
.magazine-btn {
    background-color: #673AB7; /* Warna Ungu */
    color: white;
    justify-content: center;
    border: none;
}

.card { background: white; border-radius: var(--ios-radius); padding: 20px; box-shadow: 0 4px 15px rgba(0,0,0,0.06); }

.student-item {
    display: flex; align-items: center; justify-content: space-between;
    background: #f8f8f8; padding: 15px; margin-bottom: 10px; border-radius: 12px; cursor: pointer;
    border: 1px solid transparent; transition: opacity 0.3s;
}
.student-item.checked { background: #fff9db; border: 1px solid var(--mcd-yellow); }
.student-item.checked .check { display: block; color: var(--mcd-red); }
.check { display: none; font-weight: bold; font-size: 1.2rem; }

/* STATUS LOCKED (DISIMPAN) */
.student-item.locked {
    opacity: 0.5;
    pointer-events: none; /* Halang klik */
    filter: grayscale(100%);
}

.sync-badge { font-size: 0.7rem; padding: 2px 6px; border-radius: 4px; margin-left: 5px; background: #eee; color: #888; }
.synced { background: #d4edda; color: #155724; }

.btn-green { background: #25D366; color: white; justify-content: center; }
.btn-blue { background: #229ED9; color: white; justify-content: center; }
.btn-red { background: var(--mcd-red); color: white; justify-content: center; }
.btn-yellow { background: var(--mcd-yellow); color: black; justify-content: center; }

.date-input { width: 100%; padding: 12px; border: 2px solid #eee; border-radius: 12px; margin: 15px 0; font-family: inherit; font-size: 16px; font-weight: bold; color: #333; background: #fff; -webkit-appearance: none; }

/* WARNING BOX */
.ios-warning {
    font-size: 0.85rem; background-color: #fff3cd; color: #856404;
    border: 1px solid #ffeeba; padding: 12px; border-radius: 10px;
    margin-top: 10px; text-align: center; line-height: 1.4;
}
.ios-warning strong { display: block; margin-bottom: 5px; color: #533f03; }

/* LOADING & BLOCKER */
#loading-overlay { display: flex; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(255,255,255,0.95); z-index: 10000; flex-direction: column; justify-content: center; align-items: center; }
.spinner { width: 50px; height: 50px; border: 5px solid #eee; border-top: 5px solid var(--mcd-red); border-radius: 50%; animation: spin 1s linear infinite; margin-bottom: 15px; }
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

#telegram-alert { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.95); z-index: 99999; flex-direction: column; justify-content: center; align-items: center; text-align: center; color: white; padding: 30px; }
.tg-box { background: #222; padding: 30px; border-radius: 20px; border: 2px solid var(--mcd-yellow); max-width: 400px; }

/* NEW FEATURE STYLES */
.date-selector {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    margin-bottom: 20px;
}
.date-selector p {
    margin: 0;
    font-weight: bold;
    color: #333;
}
.date-nav-btn {
    background: #f0f0f0;
    border: none;
    border-radius: 50%;
    width: 38px;
    height: 38px;
    font-size: 1.2rem;
    font-weight: bold;
    color: #555;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0;
    margin: 0;
    line-height: 1;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}
.date-nav-btn:active { background: #e0e0e0; }

.section-title {
    color: var(--mcd-red);
    margin-top: 0;
    margin-bottom: 15px;
    font-size: 1.1rem;
    text-align: center;
}
.file-input {
    width: 100%;
    padding: 12px;
    border: 2px dashed #ddd;
    border-radius: 10px;
    background-color: #f9f9f9;
    cursor: pointer;
}
#image-preview-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 10px;
    margin-top: 15px;
}
#image-preview-container img {
    width: 100%;
    height: 100px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid #eee;
}

#performance-analysis-container .analysis-grid {
    display: flex;
    flex-direction: column;
    gap: 20px;
}
#performance-analysis-container h5 {
    margin: 0 0 10px 0;
    font-size: 1rem;
    padding-bottom: 5px;
    border-bottom: 2px solid #eee;
}
.analysis-table-container {
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid #eee;
    border-radius: 8px;
}
.analysis-table {
    width: 100%;
    border-collapse: collapse;
}
.analysis-table th, .analysis-table td {
    border-bottom: 1px solid #f5f5f5;
    padding: 10px 8px;
    text-align: left;
    font-size: 0.9rem;
}
.analysis-table th {
    background-color: #f9f9f9;
    font-weight: bold;
    position: sticky;
    top: 0;
}
.analysis-table tr:last-child td {
    border-bottom: none;
}
.analysis-table td:first-child, .analysis-table th:first-child {
    text-align: center;
    padding-left: 10px;
}
.analysis-table td:last-child {
    text-align: center;
    font-weight: bold;
}
.hadir-list td:last-child { color: #155724; }
.ponteng-list td:last-child { color: #721c24; }

/* SUMMARY DETAILS */
.summary-details {
    margin-top: 20px;
    border-top: 1px dashed #ccc;
    padding-top: 15px;
}
.summary-details details {
    margin-bottom: 10px;
    border-radius: 8px;
    border: 1px solid #ddd;
    background-color: #fdfdfd;
}
.summary-details summary {
    padding: 12px 15px;
    font-weight: bold;
    cursor: pointer;
    list-style-position: inside;
    color: white;
}
.summary-details details.summary-hadir summary {
    background-color: #229ED9;
}
.summary-details details.summary-takhadir summary {
    background-color: var(--mcd-red);
}
.summary-details-content {
    padding: 15px;
    background-color: #fff;
}
.summary-details-content ol {
    padding-left: 0;
    margin: 0;
    font-size: 0.85rem;
    line-height: 1.6;
    list-style-position: inside;
    columns: 2;
    gap: 20px;
}


/* PRINT */
#print-container { display: none; }

@media print {
    @page {
        size: landscape;
        margin: 10mm;
    }
    body, html { background: white !important; height: auto !important; margin: 0 !important; padding: 0 !important; overflow: visible !important; width: 100% !important; }
    #app-ui, #telegram-alert, #loading-overlay { display: none !important; }
    #print-container { display: block !important; position: absolute; left: 0; top: 0; width: 100%; background: white; color: #000; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; }
    
    .p-page { padding: 0; width: 100%; box-sizing: border-box; page-break-after: always; }
    .p-page:last-child { page-break-after: auto; }
    .p-header { text-align: center; background-color: #DA291C !important; color: white !important; padding: 15px; border-radius: 8px 8px 0 0; -webkit-print-color-adjust: exact; print-color-adjust: exact; border-bottom: 4px solid #FFC72C; margin-bottom: 0; }
    .p-header h1 { margin: 0; font-size: 18pt; text-transform: uppercase; }
    .p-header h2 { margin: 5px 0 0; font-size: 11pt; font-weight: normal; }
    .p-info { border: 1px solid #ddd; border-top: none; padding: 10px 15px; background: #fdfdfd !important; -webkit-print-color-adjust: exact; margin-bottom: 15px; border-radius: 0 0 8px 8px; }
    .p-row { display: flex; margin-bottom: 6px; font-size: 11pt; }
    .p-label { width: 120px; font-weight: bold; color: #555; }
    .p-val { font-weight: bold; }
    .p-stats { background: #eee !important; -webkit-print-color-adjust: exact; padding: 8px; text-align: center; font-weight: bold; border-radius: 6px; border: 1px solid #ccc; margin-bottom: 15px; font-size: 10pt; }
    .p-list-title { font-size: 14pt; font-weight: bold; border-bottom: 2px solid; padding-bottom: 3px; margin-top: 15px; margin-bottom: 8px; display: block; width: 100%; page-break-after: avoid; }
    .p-grid { display: flex; flex-wrap: wrap; gap: 5px; width: 100%; }
    .p-item { width: 48%; padding: 5px 8px; font-size: 9pt; border-radius: 4px; margin-bottom: 2px; font-weight: 600; -webkit-print-color-adjust: exact; page-break-inside: avoid; }
    .p-hadir { background: #e3f2fd !important; color: #0d47a1 !important; border-left: 3px solid #0d47a1; }
    .p-takhadir { background: #ffebee !important; color: #c62828 !important; border-left: 3px solid #c62828; }
    .p-table { width: 100%; border-collapse: collapse; margin-top: 15px; }
    .p-table th, .p-table td { border: 1px solid #333 !important; padding: 8px; text-align: center; font-size: 12pt; }
    .p-table th { background: #FFC72C !important; -webkit-print-color-adjust: exact; color: black !important; }
    .p-table tr:nth-child(even) { background: #f9f9f9 !important; -webkit-print-color-adjust: exact; }
    .p-footer { margin-top: 20px; text-align: center; font-size: 8pt; color: #888; border-top: 1px solid #eee; padding-top: 5px; }
    
    .p-summary-details { margin-top: 10px; page-break-inside: avoid; }
    .p-summary-details .p-list-title { margin-top: 0; page-break-after: avoid;}
    .p-summary-details ol { list-style-position: inside; padding-left: 0; margin-bottom: 10px; columns: 4; font-size: 10pt; gap: 25px;}
    .p-summary-details li { page-break-inside: avoid; }

    /* === PRINT OPTIMIZATION v2.5 === */
    .p-image-section {
        page-break-before: always;
        break-before: page;
        padding-top: 20px;
    }
    .p-image-section .p-list-title { margin-bottom: 10px; }
    .p-image-container {
        display: grid;
        grid-template-columns: 1fr 1fr 1fr;
        grid-template-rows: 1fr 1fr;
        gap: 10px;
        height: 90vh;
    }
    .p-image-container img {
        width: 100%;
        height: 100%;
        object-fit: contain;
        border-radius: 4px;
        border: 1px solid #ddd;
        background: #f9f9f9 !important;
        padding: 5px;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
    
    .p-analysis-section { margin-top: 20px; }
    .p-analysis-grid { display: flex; flex-direction: column; gap: 20px; }
    .p-analysis-col {
        width: 100%;
        page-break-inside: avoid;
        margin-bottom: 15px;
        padding: 10px;
        border-radius: 6px;
    }
    .p-analysis-hadir-box {
        background: #e3f2fd !important;
        border-left: 4px solid #1976D2 !important;
    }
    .p-analysis-ponteng-box {
        background: #ffebee !important;
        border-left: 4px solid #c62828 !important;
    }
    .p-analysis-col h5 {
        margin-top: 0;
        margin-bottom: 10px;
        padding-bottom: 5px;
        border-bottom: 1px solid #ccc;
        font-size: 11pt;
    }
    .p-analysis-hadir-box h5 { color: #1976D2 !important; }
    .p-analysis-ponteng-box h5 { color: #c62828 !important; }

    .p-analysis-table { width: 100%; border-collapse: collapse; background: white !important; }
    .p-analysis-table th, .p-analysis-table td { border: 1px solid #333; padding: 5px; font-size: 8pt; text-align: left; }
    .p-analysis-table th { background: #eee !important; -webkit-print-color-adjust: exact; }
    .p-analysis-table .p-analysis-count { text-align: center; font-weight: bold; }
}
