@import url('https://fonts.googleapis.com/css2?family=Amiri:ital,wght@0,400;0,700;1,400&family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap');

body {
    font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
}

.font-arabic {
    font-family: 'Amiri', 'Traditional Arabic', 'Scheherazade New', serif;
}

/* Custom scrollbar for spreadsheet grids */
.spreadsheet-container::-webkit-scrollbar {
    height: 8px;
    width: 8px;
}
.spreadsheet-container::-webkit-scrollbar-track {
    background: #f1f5f9;
}
.spreadsheet-container::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}
.spreadsheet-container::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Cell inputs in spreadsheet */
.cell-input {
    width: 100%;
    height: 100%;
    border: none;
    background: transparent;
    text-align: center;
    font-size: 13px;
    font-weight: 600;
    padding: 4px;
    outline: none;
    transition: all 0.15s ease-in-out;
}
.cell-input:focus {
    background-color: #ecfdf5;
    box-shadow: inset 0 0 0 2px #059669;
    border-radius: 2px;
}
.cell-red {
    background-color: #fee2e2 !important;
    color: #b91c1c !important;
}
.cell-red:focus {
    background-color: #fef2f2 !important;
    box-shadow: inset 0 0 0 2px #dc2626 !important;
}

.attendance-mobile-view {
    display: none;
}

.attendance-table {
    min-width: 1240px;
    table-layout: fixed;
}

.attendance-student-number {
    width: 52px;
}

.attendance-student-name {
    width: 210px;
}

.attendance-month-heading {
    min-width: 204px;
    background: #e2e8f0;
    color: #1e293b;
    font-size: 12px;
}

.attendance-type-heading,
.attendance-input-cell {
    width: 68px;
    min-width: 68px;
}

.attendance-type-heading {
    background: #f8fafc;
    color: #475569;
    font-size: 10px;
}

.attendance-input {
    display: block;
    width: 100%;
    min-width: 0;
    min-height: 40px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background: #fff;
    color: #0f172a;
    text-align: center;
    font-size: 14px;
    font-weight: 700;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

.attendance-input:focus {
    border-color: #059669;
    background: #ecfdf5;
    box-shadow: 0 0 0 2px rgb(5 150 105 / 18%);
}

.attendance-input:disabled {
    background: #f1f5f9;
    color: #64748b;
}

.app-shell {
    position: relative;
}

.app-shell > .flex-1 {
    min-width: 0;
}

.sidebar-backdrop {
    display: none;
}

.mobile-bottom-nav {
    display: none;
}

@media (max-width: 767px) {
    /* Terikat status login: shell hanya boleh dipaksa block bila pengguna
       sudah login (data-authed="true"), agar di mobile form login tidak
       diikuti sisa konten dashboard di bawahnya. */
    .app-shell[data-authed="true"] {
        display: block !important;
        height: 100dvh;
        overflow: hidden;
    }

    /* Sidebar jadi drawer overlay (bukan hilang total): tampil bila
       sidebarVisible=true, terlepas atas konten, dan bisa ditutup
       lewat tombol topbar atau backdrop. */
    .app-shell > aside {
        position: fixed;
        top: 0;
        bottom: 0;
        left: 0;
        z-index: 55;
    }

    .sidebar-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 40;
        background: rgba(2, 6, 23, 0.55);
    }

    .app-shell > .flex-1 {
        width: 100%;
        height: 100%;
    }

    .app-shell .app-topbar {
        display: flex !important;
        flex-direction: column;
        align-items: stretch;
        justify-content: flex-start;
        gap: 8px;
        padding: 10px 12px !important;
        flex-wrap: nowrap;
    }

    .app-shell .app-topbar > .topbar-menu {
        width: 100%;
        display: flex;
        justify-content: space-between;
    }

    .app-shell .app-topbar > .topbar-context {
        width: 100%;
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        align-items: stretch;
        gap: 6px;
    }

    .app-shell .app-topbar > .topbar-context > label {
        grid-column: 1 / -1;
        justify-content: space-between;
    }

    .app-shell .topbar-context > label,
    .app-shell .topbar-context > div {
        min-width: 0;
        max-width: 100%;
        overflow-wrap: anywhere;
    }

    .app-shell .topbar-context > label select {
        flex: 1;
        width: 1px;
        text-align: right;
    }

    .app-shell .app-topbar > .topbar-actions {
        width: 100%;
        justify-content: flex-start;
        gap: 6px;
    }

    .app-shell .topbar-save-status {
        max-width: 100%;
    }

    .app-shell .topbar-save-status [role="alert"] {
        max-width: 140px;
        overflow-wrap: anywhere;
    }

    .app-shell .topbar-role {
        font-size: 10px;
    }

    .app-shell .topbar-grade-actions {
        display: none !important;
    }

    .app-shell .topbar-print-action {
        margin-left: auto;
        padding: 8px 10px !important;
        font-size: 11px !important;
    }

    .app-shell main {
        padding: 14px 12px 90px !important;
    }

    .app-shell .rounded-xl,
    .app-shell .rounded-2xl,
    .app-shell .bg-white,
    .app-shell .bg-slate-50 {
        border-radius: 16px !important;
    }

    .app-shell input,
    .app-shell select,
    .app-shell textarea,
    .app-shell button,
    .app-shell a {
        min-height: 2.5rem;
    }

    .attendance-desktop-view {
        display: none;
    }

    .attendance-mobile-view {
        display: block;
    }

    .attendance-mobile-input {
        min-height: 42px;
        padding: 4px 2px;
        font-size: 14px;
    }

    .student-action-group {
        display: flex;
        flex-direction: column;
        gap: 6px;
        width: 100%;
    }

    .student-action-button {
        width: 100%;
        padding: 0.55rem 0.5rem;
        border-radius: 10px;
        font-size: 10px;
        font-weight: 700;
        transition: all 0.2s ease;
    }

    .student-action-primary {
        background: #ecfdf5;
        color: #047857;
        border: 1px solid #a7f3d0;
    }

    .student-action-secondary {
        background: #eff6ff;
        color: #1d4ed8;
        border: 1px solid #bfdbfe;
    }

    .student-action-danger {
        background: #fef2f2;
        color: #b91c1c;
        border: 1px solid #fecaca;
    }

    .student-action-danger:hover:not(:disabled) {
        background: #b91c1c;
        color: #fff;
    }

    @media (min-width: 768px) {
        .student-action-group {
            display: flex;
            flex-direction: row;
            justify-content: center;
            align-items: center;
            gap: 8px;
        }

        .student-action-button {
            width: auto;
            min-width: 96px;
            padding: 0.45rem 0.7rem;
            font-size: 11px;
        }
    }

    .mobile-bottom-nav {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 60;
        display: flex;
        align-items: center;
        justify-content: space-around;
        gap: 4px;
        background: rgba(15, 23, 42, 0.96);
        border-top: 1px solid rgba(148, 163, 184, 0.24);
        backdrop-filter: blur(12px);
        padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
        box-shadow: 0 -10px 25px rgba(15, 23, 42, 0.2);
    }

    .mobile-bottom-nav button {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 3px;
        color: #cbd5e1;
        font-size: 10px;
        font-weight: 600;
        border-radius: 12px;
        padding: 8px 4px 7px;
        background: transparent;
        border: none;
    }

    .mobile-bottom-nav button svg {
        width: 18px;
        height: 18px;
    }

    .mobile-bottom-nav button.active {
        background: rgba(16, 185, 129, 0.15);
        color: #d1fae5;
    }
}

/* Print utilities */
@media print {
    .no-print {
        display: none !important;
    }
}
