/**
 * =======================================================================
 * PORTAL KEHADIRAN SISWA - SMK WIDYA YAHYA
 * Modern EdTech Mobile App Design System (Inspired by kehadiran.png)
 * =======================================================================
 */

:root {
    --b: #0755c9;
    --b2: #287bfa;
    --navy: #102a68;
    --ink: #1a315f;
    --muted: #7182a4;
    --line: #dce8fb;
    --green: #12b76a;
    --yellow: #f5b51b;
    --blue: #2584f5;
    --red: #ef4444;
    --amber: #f97316;
    --purple: #9333ea;
    --shadow: 0 8px 24px rgba(27, 86, 170, 0.10);
    --card-bg: rgba(255, 255, 255, 0.95);
}

*, *::before, *::after {
    box-sizing: border-box;
    font-family: 'Roboto', 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    margin: 0;
    padding: 0;
    background-color: #eaf1fb;
    color: var(--ink);
    min-height: 100vh;
    line-height: 1.5;
}

/* App Mobile Shell Container */
.app {
    width: min(100%, 540px);
    min-height: 100vh;
    margin: 0 auto;
    background: linear-gradient(180deg, #eaf4ff 0%, #f7faff 370px, #f4f8ff 100%);
    padding-bottom: 32px;
    position: relative;
    overflow-x: hidden;
    box-shadow: 0 0 35px rgba(28, 65, 120, 0.12);
}

.app.has-bottom-nav {
    padding-bottom: 96px;
}

@media (min-width: 600px) {
    body {
        padding: 24px 0;
    }
    .app {
        border-radius: 28px;
        min-height: 920px;
        box-shadow: 0 12px 40px rgba(16, 42, 104, 0.18);
    }
}

/* 1. Hero Header Section */
.hero {
    min-height: 165px;
    padding: 22px 20px 24px;
    color: #ffffff;
    position: relative;
    overflow: hidden;
    background: url('../images/hero_kehadiran.webp') right center / cover no-repeat, linear-gradient(112deg, #06368f 0%, #075bd6 55%, #328df6 100%);
}

.hero::before {
    content: "";
    position: absolute;
    width: 360px;
    height: 260px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.12);
    right: -120px;
    top: -160px;
    pointer-events: none;
}

.hero::after {
    content: "";
    position: absolute;
    left: -35px;
    right: -35px;
    bottom: -35px;
    height: 75px;
    border-top: 6px solid #ffcf32;
    border-radius: 50%;
    transform: rotate(-4deg);
    pointer-events: none;
}

.head {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    gap: 13px;
}

.logo-badge {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: #ffffff;
    border: 3px solid rgba(255, 255, 255, 0.85);
    display: grid;
    place-items: center;
    box-shadow: 0 5px 16px rgba(0, 42, 122, 0.35);
    flex: none;
    overflow: hidden;
}

.logo-badge img {
    width: 44px;
    height: 44px;
    object-fit: contain;
}

.school-info {
    min-width: 0;
}

.school-info h1 {
    font-size: 19px;
    margin: 0;
    font-weight: 900;
    letter-spacing: -0.02em;
    line-height: 1.1;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}

.school-info p {
    font-size: 11.5px;
    margin: 4px 0 0;
    color: #e5f1ff;
    font-weight: 500;
}

.exit-btn {
    margin-left: auto;
    border: 1px solid rgba(255, 255, 255, 0.35);
    background: rgba(255, 255, 255, 0.18);
    backdrop-filter: blur(8px);
    color: #ffffff;
    border-radius: 24px;
    padding: 8px 14px;
    font-weight: 750;
    font-size: 12px;
    white-space: nowrap;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.exit-btn:hover {
    background: rgba(225, 29, 72, 0.85);
    border-color: rgba(244, 63, 94, 0.9);
}

/* 2. Main Content Panels */
main {
    padding: 0 16px;
}

.panel {
    background: var(--card-bg);
    border: 1px solid #d8e6fb;
    border-radius: 22px;
    box-shadow: var(--shadow);
    margin-bottom: 14px;
}

/* 3. Search Box Card */
.search-panel {
    margin-top: -18px;
    padding: 14px;
    position: relative;
    z-index: 3;
}

.search-row {
    display: flex;
    gap: 9px;
}

.search-input-box {
    height: 48px;
    display: flex;
    align-items: center;
    gap: 10px;
    border: 1.5px solid #c9d9f1;
    border-radius: 15px;
    background: #f8fbff;
    padding: 0 14px;
    flex: 1;
    min-width: 0;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.search-input-box:focus-within {
    background: #ffffff;
    border-color: #287bfa;
    box-shadow: 0 0 0 3px rgba(40, 123, 250, 0.15);
}

.search-input-box svg,
.search-input-box i {
    width: 18px;
    height: 18px;
    color: #60799e;
    flex: none;
}

.search-input-box input {
    border: 0;
    outline: 0;
    background: transparent;
    width: 100%;
    min-width: 0;
    color: #1a315f;
    font-size: 14px;
    font-weight: 700;
}

.search-input-box input::placeholder {
    color: #94a3b8;
    font-weight: 400;
}

.search-btn {
    border: 0;
    border-radius: 15px;
    background: linear-gradient(135deg, #2878fa 0%, #0754d2 100%);
    color: #ffffff;
    padding: 0 20px;
    font-weight: 800;
    font-size: 14px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(7, 84, 210, 0.25);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.search-btn:active {
    transform: scale(0.97);
}

.period-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    border-top: 1px solid #edf2fa;
    margin-top: 11px;
    padding-top: 10px;
}

.period-label {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    font-weight: 750;
    color: #657796;
    margin-right: auto;
}

.period-label svg,
.period-label i {
    width: 15px;
    height: 15px;
    color: #287bfa;
}

.period-select {
    border: 1px solid #d8e3f3;
    background: #f7faff;
    border-radius: 13px;
    padding: 7px 10px;
    color: #26385d;
    font-size: 12px;
    font-weight: 750;
    outline: none;
    cursor: pointer;
    transition: border-color 0.15s ease;
}

.period-select:focus {
    border-color: #287bfa;
}

/* 4. Student Profile Card */
.student-card {
    padding: 15px;
    display: grid;
    grid-template-columns: 78px 1fr auto;
    gap: 12px;
    align-items: center;
}

.student-avatar {
    width: 78px;
    height: 86px;
    border-radius: 18px;
    background: linear-gradient(145deg, #e6f2ff, #b8d9ff);
    border: 2px solid #91bfff;
    display: grid;
    place-items: center;
    overflow: hidden;
    box-shadow: inset 0 2px 8px #ffffff, 0 4px 12px rgba(16, 42, 104, 0.08);
    flex: none;
}

.student-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.student-info {
    min-width: 0;
}

.student-top-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 4px;
}

.status-badge-active {
    border-radius: 20px;
    background: #d9fbe9;
    color: #07874e;
    padding: 4px 9px;
    font-size: 10px;
    font-weight: 850;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.status-badge-active::before {
    content: "●";
    font-size: 8px;
    color: #12b76a;
}

.nis-meta {
    font-size: 12px;
    color: #657796;
    font-weight: 700;
}

.nis-meta strong {
    color: #1a315f;
}

.student-name {
    font-size: 18px;
    margin: 0 0 4px;
    color: #102a68;
    font-weight: 900;
    line-height: 1.15;
    letter-spacing: -0.02em;
}

.student-meta-desc {
    font-size: 11.5px;
    line-height: 1.45;
    margin: 0;
    color: #586b8d;
}

.student-meta-desc b {
    color: #1768df;
}

.print-btn {
    align-self: start;
    border: 1px solid #dce7f7;
    background: #f3f7ff;
    border-radius: 13px;
    color: #344a70;
    padding: 8px 12px;
    font-size: 12px;
    font-weight: 750;
    white-space: nowrap;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    transition: all 0.15s ease;
}

.print-btn:hover {
    background: #e5efff;
    border-color: #b9d7ff;
    color: #0755c9;
}

/* 5. Summary Stats & Donut Ring Card */
.stats-panel {
    padding: 14px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.stats-grid {
    flex: 1;
    min-width: 0;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px 4px;
}

.stat-item {
    text-align: center;
    padding: 4px 2px;
    border-right: 1px solid #e2ebf8;
}

.stat-item:nth-child(3n) {
    border-right: none;
}

.stat-name {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    font-size: 10.5px;
    font-weight: 700;
    color: #536687;
    white-space: nowrap;
}

.dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    display: inline-block;
    flex: none;
}

.dot.g { background: var(--green); }
.dot.y { background: var(--yellow); }
.dot.bl { background: var(--blue); }
.dot.r { background: var(--red); }
.dot.am { background: var(--amber); }
.dot.pr { background: var(--purple); }
.dot.gr { background: #8796ad; }

.stat-num {
    display: block;
    font-size: 13.5px;
    font-weight: 900;
    color: #102a68;
    margin-top: 3px;
    line-height: 1.1;
}

/* Donut Ring Indicator */
.ring-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    border-left: 2px solid #b7d4ff;
    padding-left: 10px;
    flex: none;
}

.ring-chart {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    position: relative;
    box-shadow: 0 4px 14px rgba(18, 183, 106, 0.15);
}

.ring-chart::before {
    content: "";
    position: absolute;
    inset: 9px;
    border-radius: 50%;
    background: #ffffff;
}

.ring-chart b {
    position: relative;
    font-size: 16px;
    font-weight: 900;
    color: #102a68;
    letter-spacing: -0.02em;
}

.ring-label {
    font-size: 10.5px;
    font-weight: 800;
    color: #475569;
}

/* 6. Calendar Section (Pixel-Perfect from kehadiran.png) */
.calendar-panel {
    overflow: hidden;
}

.cal-head {
    background: linear-gradient(105deg, #0d2e91 0%, #0758ca 72%, #1a75e8 100%);
    color: #ffffff;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.cal-head svg,
.cal-head i {
    width: 22px;
    height: 22px;
    flex: none;
}

.cal-head h3 {
    font-size: 14.5px;
    margin: 0;
    font-weight: 850;
    letter-spacing: -0.01em;
}

.cal-body {
    padding: 13px 12px;
}

.hint-box {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #e9f3ff;
    border-radius: 14px;
    padding: 9px 12px;
    color: #254b8a;
    font-size: 11.5px;
    line-height: 1.35;
    margin-bottom: 12px;
}

.info-icon {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #1976e9;
    color: #ffffff;
    display: grid;
    place-items: center;
    font-weight: 900;
    font-size: 12px;
    flex: none;
}

/* Calendar Grid */
.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 4.5px;
}

.weekday-cell {
    text-align: center;
    font-size: 10px;
    font-weight: 850;
    color: #566b8d;
    padding: 6px 0 5px;
    background: #f0f5fc;
    border-radius: 8px;
    text-transform: uppercase;
}

.weekday-cell.saturday {
    background: #eff4fc;
    color: #2563eb;
}

.weekday-cell.sunday {
    background: #fee2e2;
    color: #ef4444;
}

.day-cell {
    min-height: 48px;
    border: 1px solid #dbe6f6;
    border-radius: 11px;
    background: #ffffff;
    padding: 4px 4px 3px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: space-between;
    color: #263d68;
    font-size: 11px;
    font-weight: 750;
    position: relative;
    cursor: pointer;
    user-select: none;
    transition: all 0.15s ease;
}

.day-cell:hover {
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(7, 85, 201, 0.12);
}

.day-cell.empty {
    background: #f9fbff;
    border-style: dashed;
    border-color: #edf2fa;
    cursor: default;
    opacity: 0.6;
}

.day-cell.weekendday {
    background: #fbfbfd;
    color: #e24a61;
}

.day-cell.sunday-cell {
    background: #fff8f8;
    color: #ef4444;
}

.day-cell.holiday-cell {
    background: #f1f5f9;
    border-color: #e2e8f0;
}

/* Status Variants on Day Cell */
.day-cell.present {
    background: linear-gradient(145deg, #e8fff2, #d9f8e7);
    border-color: #bbf0cf;
}

.day-cell.sick {
    background: #fff8e5;
    border-color: #f7e4a9;
}

.day-cell.permission {
    background: #edf5ff;
    border-color: #cfe2ff;
}

.day-cell.alpha {
    background: #fef2f2;
    border-color: #fecaca;
}

.day-cell.bolosed {
    background: #fefce8;
    border-color: #fef08a;
}

.day-cell.dispensed {
    background: #faf5ff;
    border-color: #e9d5ff;
}

.day-cell.selected {
    outline: 2px solid #2679ef;
    outline-offset: 1px;
    z-index: 2;
}

.day-num {
    font-size: 10px;
    font-weight: 800;
    line-height: 1;
}

.day-mark {
    align-self: center;
    font-size: 14px;
    font-weight: 900;
    line-height: 1;
    margin-top: 1px;
}

.present .day-mark { color: #0aa65b; }
.sick .day-mark { color: #d97706; }
.permission .day-mark { color: #1474df; }
.alpha .day-mark { color: #dc2626; }
.bolosed .day-mark { color: #d97706; }
.dispensed .day-mark { color: #9333ea; }
.unrecorded .day-mark { color: #94a3b8; font-weight: 700; }

/* Interactive Detail Callout Box */
.day-detail-callout {
    display: none;
    margin-top: 12px;
    border: 1px solid #cfe0fa;
    background: #f5f9ff;
    border-radius: 14px;
    padding: 11px 13px;
    font-size: 12px;
    color: #40577d;
    line-height: 1.55;
    animation: fadeIn 0.25s ease-out;
}

.day-detail-callout.show {
    display: block;
}

.day-detail-callout b {
    color: #183d82;
}

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

/* Legend */
.legend-bar {
    margin-top: 13px;
    border-radius: 14px;
    background: #f0f5ff;
    padding: 10px 8px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 9px;
    flex-wrap: wrap;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 10.5px;
    font-weight: 700;
    color: #435777;
    white-space: nowrap;
}

/* 7. Detailed Sessions Breakdown (Riwayat Harian) */
.history-panel {
    padding: 14px 15px;
}

.history-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid #edf2fa;
}

.history-head h4 {
    font-size: 14px;
    font-weight: 850;
    margin: 0;
    color: #102a68;
}

.history-head p {
    font-size: 11px;
    color: #64748b;
    margin: 2px 0 0;
}

.day-session-card {
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    overflow: hidden;
    margin-bottom: 9px;
    background: #ffffff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
}

.day-session-header {
    padding: 10px 12px;
    background: #f8fbff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid #edf2fa;
}

.day-session-header:hover {
    background: #f0f6ff;
}

.day-date-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.day-badge-square {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: #ffffff;
    border: 1px solid #dce7f7;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    line-height: 1;
    font-weight: 900;
    color: #0755c9;
}

.day-badge-square span {
    font-size: 8px;
    text-transform: uppercase;
    color: #94a3b8;
}

.session-row-item {
    padding: 9px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid #f1f5f9;
    font-size: 11.5px;
}

.session-row-item:last-child {
    border-bottom: none;
}

/* 8. Bottom App Navigation Bar */
.bottom-nav {
    position: fixed;
    z-index: 50;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: min(540px, 100%);
    height: 76px;
    background: linear-gradient(110deg, #073a9c 0%, #0758ca 60%, #0b3f9e 100%);
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    padding: 7px 10px max(7px, env(safe-area-inset-bottom));
    box-shadow: 0 -7px 22px rgba(22, 75, 156, 0.2);
    border-radius: 22px 22px 0 0;
}

.bottom-nav button,
.bottom-nav a {
    border: 0;
    outline: none;
    background: transparent;
    color: #dceaff;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 4px;
    border-radius: 16px;
    font-size: 11px;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}

.bottom-nav svg,
.bottom-nav i {
    width: 20px;
    height: 20px;
}

.bottom-nav button.active,
.bottom-nav button:hover,
.bottom-nav a.active,
.bottom-nav a:hover {
    background: linear-gradient(145deg, #2588ff, #0870ee);
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(0, 56, 140, 0.4), inset 0 1px 2px rgba(255, 255, 255, 0.4);
}

@media (min-width: 600px) {
    .bottom-nav {
        bottom: 24px;
        border-radius: 22px;
    }
}

/* Print Layout */
@media print {
    body {
        background: #ffffff !important;
        padding: 0 !important;
    }
    .app {
        box-shadow: none !important;
        width: 100% !important;
        max-width: 100% !important;
        padding-bottom: 0 !important;
    }
    .bottom-nav, .exit-btn, .search-btn, .print-btn, .hint-box {
        display: none !important;
    }
    .panel {
        box-shadow: none !important;
        border: 1px solid #cbd5e1 !important;
        break-inside: avoid;
    }
    .day-sessions-content {
        display: block !important;
    }
}
