:root { --primary: #1e3a8a; --secondary: #10b981; --bg: #f3f4f6; --text: #374151; --sidebar: #111827; }
body { font-family: sans-serif; margin: 0; background-color: var(--bg); color: var(--text); display: flex; min-height: 100vh; }
.login-wrapper {
    position:relative;
    display:flex;
    justify-content:center;
    align-items:center;
    width:100%;
    min-height:100vh;
    padding:24px;
    box-sizing:border-box;
    overflow:hidden;
    background:
        radial-gradient(circle at 12% 16%, rgba(255,255,255,.18) 0 90px, transparent 91px),
        radial-gradient(circle at 88% 82%, rgba(16,185,129,.24) 0 130px, transparent 131px),
        linear-gradient(145deg, #0f2a6b 0%, #1e3a8a 42%, #2563eb 100%);
}
.login-wrapper::before,
.login-wrapper::after {
    content:"";
    position:absolute;
    border-radius:999px;
    background:rgba(255,255,255,.08);
    pointer-events:none;
}
.login-wrapper::before {
    width:260px;
    height:260px;
    left:-90px;
    bottom:-90px;
}
.login-wrapper::after {
    width:180px;
    height:180px;
    right:-55px;
    top:-50px;
}
.login-box {
    position:relative;
    z-index:2;
    background:rgba(255,255,255,.98);
    padding:34px 32px 28px;
    border-radius:22px;
    box-shadow:0 24px 70px rgba(15,23,42,.30);
    width:100%;
    max-width:420px;
    text-align:center;
    border:1px solid rgba(255,255,255,.8);
}
.login-brand-logo {
    width:84px;
    height:84px;
    margin:0 auto 13px;
    border-radius:22px;
    background:#eff6ff;
    display:flex;
    justify-content:center;
    align-items:center;
    overflow:hidden;
    box-shadow:0 8px 22px rgba(30,58,138,.14);
    border:1px solid #dbeafe;
}
.login-brand-logo img {
    max-width:70px;
    max-height:70px;
    object-fit:contain;
}
.login-brand-fallback {
    font-size:2.3rem;
}
.login-app-title {
    color:#172554;
    margin:0;
    font-size:1.55rem;
    font-weight:800;
    letter-spacing:-.02em;
}
.login-app-subtitle {
    margin:6px 0 24px;
    color:#64748b;
    font-size:.9rem;
    line-height:1.5;
}
.login-field {
    position:relative;
    margin-bottom:13px;
    text-align:left;
}
.login-field-icon {
    position:absolute;
    left:13px;
    top:50%;
    transform:translateY(-50%);
    width:30px;
    text-align:center;
    font-size:1.05rem;
    pointer-events:none;
}
.login-box input {
    width:100%;
    padding:13px 14px 13px 45px;
    margin:0;
    border:1px solid #cbd5e1;
    border-radius:12px;
    box-sizing:border-box;
    background:#f8fafc;
    color:#0f172a;
    font-size:.95rem;
    transition:.2s;
    outline:none;
}
.login-box input:focus {
    background:#fff;
    border-color:#3b82f6;
    box-shadow:0 0 0 4px rgba(59,130,246,.12);
}
.login-box .login-password-input {
    padding-right:58px;
}
.login-password-input::-ms-reveal,
.login-password-input::-ms-clear {
    display:none;
}
.login-box button.login-password-toggle {
    position:absolute;
    right:5px;
    top:50%;
    transform:translateY(-50%);
    display:inline-flex;
    align-items:center;
    justify-content:center;
    width:40px;
    height:40px;
    padding:0;
    margin:0;
    border:none;
    border-radius:8px;
    background:transparent;
    color:#64748b;
    cursor:pointer;
}
.login-box button.login-password-toggle:hover {
    background:#e2e8f0;
    color:#1e3a8a;
}
.login-box button.login-password-toggle:focus-visible {
    outline:2px solid #3b82f6;
    outline-offset:1px;
}
.login-password-toggle[aria-pressed="false"] .login-password-slash {
    display:none;
}
.login-box button.login-submit {
    width:100%;
    padding:13px 16px;
    background:linear-gradient(135deg,#059669,#10b981);
    color:white;
    border:none;
    border-radius:12px;
    font-weight:800;
    cursor:pointer;
    font-size:1rem;
    box-shadow:0 10px 24px rgba(16,185,129,.25);
    transition:transform .15s, box-shadow .15s;
}
.login-box button.login-submit:hover {
    transform:translateY(-1px);
    box-shadow:0 13px 28px rgba(16,185,129,.30);
}
.login-security-note {
    margin:16px 0 0;
    padding-top:14px;
    border-top:1px solid #e2e8f0;
    color:#64748b;
    font-size:.75rem;
    line-height:1.5;
}
.login-school-address {
    margin-top:10px;
    color:#94a3b8;
    font-size:.72rem;
    line-height:1.45;
}

/* ============================================================
   BERANDA APLIKASI SISWA & WALI
   ============================================================ */
.portal-app-home {
    max-width:1050px;
    margin:0 auto;
}
.portal-app-hero {
    position:relative;
    overflow:hidden;
    padding:24px;
    margin-bottom:18px;
    border-radius:20px;
    background:linear-gradient(135deg,#1e3a8a 0%,#2563eb 58%,#0ea5e9 100%);
    color:#fff;
    box-shadow:0 14px 34px rgba(30,58,138,.20);
}
.portal-app-hero::after {
    content:"";
    position:absolute;
    width:180px;
    height:180px;
    border-radius:999px;
    right:-55px;
    bottom:-95px;
    background:rgba(255,255,255,.12);
}
.portal-app-hero-top {
    position:relative;
    z-index:2;
    display:flex;
    align-items:center;
    gap:15px;
}
.portal-app-avatar {
    width:58px;
    height:58px;
    border-radius:18px;
    background:rgba(255,255,255,.18);
    border:1px solid rgba(255,255,255,.28);
    display:flex;
    align-items:center;
    justify-content:center;
    font-size:1.8rem;
    flex:0 0 auto;
}
.portal-app-hero h2 {
    margin:0 0 4px;
    font-size:1.35rem;
}
.portal-app-hero p {
    margin:0;
    color:#dbeafe;
    font-size:.87rem;
    line-height:1.45;
}
.portal-app-section-title {
    margin:0 0 11px;
    color:#334155;
    font-size:.92rem;
    font-weight:800;
}
.portal-app-grid {
    display:grid;
    grid-template-columns:repeat(4,minmax(0,1fr));
    gap:13px;
}
.portal-app-tile {
    position:relative;
    display:flex;
    flex-direction:column;
    align-items:center;
    justify-content:center;
    min-height:132px;
    padding:16px 10px;
    box-sizing:border-box;
    border:1px solid #e2e8f0;
    border-radius:18px;
    background:#fff;
    box-shadow:0 5px 17px rgba(15,23,42,.06);
    cursor:pointer;
    text-align:center;
    transition:transform .16s, box-shadow .16s, border-color .16s;
    user-select:none;
}
.portal-app-tile:hover {
    transform:translateY(-3px);
    box-shadow:0 12px 26px rgba(15,23,42,.12);
    border-color:#bfdbfe;
}
.portal-app-icon {
    width:54px;
    height:54px;
    margin-bottom:10px;
    border-radius:17px;
    display:flex;
    align-items:center;
    justify-content:center;
    font-size:1.65rem;
    background:#eff6ff;
    color:#1d4ed8;
}
.portal-app-tile.green .portal-app-icon { background:#ecfdf5; color:#047857; }
.portal-app-tile.orange .portal-app-icon { background:#fff7ed; color:#c2410c; }
.portal-app-tile.purple .portal-app-icon { background:#faf5ff; color:#7e22ce; }
.portal-app-tile.rose .portal-app-icon { background:#fff1f2; color:#be123c; }
.portal-app-tile.cyan .portal-app-icon { background:#ecfeff; color:#0e7490; }
.portal-app-tile.slate .portal-app-icon { background:#f1f5f9; color:#334155; }
.portal-app-tile-title {
    font-size:.88rem;
    font-weight:800;
    color:#1e293b;
    line-height:1.3;
}
.portal-app-tile-sub {
    margin-top:4px;
    font-size:.7rem;
    line-height:1.35;
    color:#94a3b8;
}
.portal-app-bottom-note {
    margin-top:18px;
    padding:12px 14px;
    border-radius:12px;
    background:#f8fafc;
    border:1px solid #e2e8f0;
    color:#64748b;
    font-size:.78rem;
    line-height:1.5;
}
.portal-home-menu-item {
    border-left:4px solid #38bdf8 !important;
}

/* Portal siswa/wali tampil sebagai aplikasi halaman-per-halaman */
body.portal-no-tabs .sidebar {
    display:none !important;
}
body.portal-no-tabs .header-mobile {
    display:none !important;
}
body.portal-no-tabs .main-content {
    width:100% !important;
    flex:1 1 100%;
    padding:18px !important;
}
body.portal-no-tabs .tab-content {
    display:none !important;
}
body.portal-no-tabs .tab-content.active {
    display:block !important;
}
.portal-back-home-wrap {
    width:100%;
    max-width:none;
    margin:0 0 14px;
    padding:0;
    box-sizing:border-box;
    text-align:left;
}
.portal-back-home-btn {
    display:inline-flex;
    align-items:center;
    gap:7px;
    padding:9px 13px;
    border:1px solid #cbd5e1;
    border-radius:11px;
    background:#fff;
    color:#1e3a8a;
    text-decoration:none;
    font-size:.84rem;
    font-weight:800;
    box-shadow:0 4px 12px rgba(15,23,42,.06);
}
.portal-back-home-btn:hover {
    background:#eff6ff;
    border-color:#93c5fd;
}
@media (max-width:600px) {
    body.portal-no-tabs .main-content {
        padding:12px !important;
    }
    .portal-back-home-btn {
        width:auto;
        max-width:100%;
        box-sizing:border-box;
        justify-content:flex-start;
    }
}
@media (max-width: 900px) {
    .portal-app-grid {
        grid-template-columns:repeat(3,minmax(0,1fr));
    }
}
@media (max-width: 600px) {
    .login-wrapper {
        padding:16px;
        align-items:center;
    }
    .login-box {
        padding:27px 20px 22px;
        border-radius:19px;
    }
    .portal-app-grid {
        grid-template-columns:repeat(3,minmax(0,1fr));
        gap:9px;
    }
    .portal-app-tile {
        min-height:112px;
        padding:12px 6px;
        border-radius:15px;
    }
    .portal-app-icon {
        width:46px;
        height:46px;
        border-radius:14px;
        font-size:1.4rem;
        margin-bottom:8px;
    }
    .portal-app-tile-title {
        font-size:.77rem;
    }
    .portal-app-tile-sub {
        display:none;
    }
    .portal-app-hero {
        padding:19px;
        border-radius:17px;
    }
}
.sidebar { width: 250px; background: var(--sidebar); color: white; transition: all 0.3s; display: flex; flex-direction: column; }
.sidebar-header { padding: 20px; font-size: 1.2rem; font-weight: bold; border-bottom: 1px solid #374151; text-align: center; }
.menu-item { padding: 15px 20px; cursor: pointer; display: flex; align-items: center; gap: 10px; border-bottom: 1px solid #1f2937; transition: 0.2s; font-size: 0.95rem; text-decoration:none; color:white;}
.menu-item:hover, .menu-item.active { background: var(--primary); }
.main-content {
    flex: 1;
    padding: 20px;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
    overflow-x: hidden;
}
.topbar {
    background: white;
    padding: 15px 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap:10px;
    flex-wrap:wrap;
    min-width:0;
    max-width:100%;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.header-mobile { display: none; background: var(--primary); color: white; padding: 15px; justify-content: space-between; align-items: center; }
.btn-toggle { background: transparent; border: none; color: white; font-size: 1.5rem; cursor: pointer; }
.card {
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    margin-bottom: 20px;
    width:100%;
    max-width:100%;
    min-width:0;
    box-sizing:border-box;
    overflow-wrap:anywhere;
}
.grid-2 {
    display:grid;
    grid-template-columns:minmax(0,1fr) minmax(0,1fr);
    gap:20px;
    width:100%;
    max-width:100%;
    min-width:0;
}
.grid-3 {
    display:grid;
    grid-template-columns:repeat(3,minmax(0,1fr));
    gap:15px;
    width:100%;
    max-width:100%;
    min-width:0;
}
.grid-2 > *,
.grid-3 > *,
.tab-content,
.tab-content > *,
form,
fieldset {
    min-width:0;
    max-width:100%;
}
.stat-box { background: var(--primary); color: white; padding: 20px; border-radius: 8px; text-align: center; font-size: 1.2rem; }
.stat-box h2 { margin: 10px 0 0 0; font-size: 2.5rem; }
.form-group { margin-bottom: 15px; }
.form-group label { display: block; margin-bottom: 5px; font-weight: bold; font-size: 0.9rem; }
.form-group input,
.form-group select,
.form-group textarea {
    width:100%;
    max-width:100%;
    min-width:0;
    padding:10px;
    box-sizing:border-box;
    border:1px solid #d1d5db;
    border-radius:4px;
    font-family:inherit;
}
.select2-container {
    max-width:100% !important;
    min-width:0 !important;
}
img,
video,
canvas,
iframe {
    max-width:100%;
}
img,
video {
    height:auto;
}
button { background: var(--secondary); color: white; padding: 10px 15px; border: none; border-radius: 4px; cursor: pointer; font-weight: bold; }
.btn-outline { background: transparent; border: 1px solid var(--primary); color: var(--primary); padding: 5px 10px; text-decoration:none; display:inline-block; border-radius:4px;}
.btn-warning { background: #f59e0b; color: white; border: none; padding: 6px 12px; border-radius: 4px; text-decoration: none; display: inline-block; font-size:0.8rem; cursor:pointer;}
.btn-danger { background: #ef4444; color: white; border: none; padding: 6px 12px; border-radius: 4px; text-decoration: none; display: inline-block; font-size:0.8rem; cursor:pointer;}
.btn-success { background: #10b981; color: white; border: none; padding: 6px 12px; border-radius: 4px; text-decoration: none; display: inline-block; font-size:0.8rem; cursor:pointer;}
.btn-copy { background: #8b5cf6; padding: 5px 10px; font-size: 0.8rem; border-radius: 4px; color:white; border:none; cursor:pointer; text-decoration:none;}
.table-responsive {
    width:100%;
    max-width:100%;
    min-width:0;
    overflow-x:auto;
    overflow-y:hidden;
    -webkit-overflow-scrolling:touch;
}
table {
    width:100%;
    max-width:100%;
    min-width:0;
    border-collapse:collapse;
    margin-top:10px;
}
.table-responsive > table,
.table-responsive table.display,
.table-responsive table.table-matrix {
    min-width:760px;
    table-layout:auto;
}

/*
 * Responsif tidak berarti memaksa semua kolom mengecil.
 * Header dijaga satu baris dan sel memperoleh lebar minimum
 * yang layak. Bila kolom banyak, wrapper yang digeser horizontal.
 */
.table-responsive th {
    white-space:nowrap;
    word-break:normal;
    overflow-wrap:normal;
}

.table-responsive td {
    min-width:90px;
    word-break:normal;
    overflow-wrap:break-word;
}

.table-responsive .col-date {
    min-width:105px !important;
    width:105px;
    white-space:nowrap !important;
}

.table-responsive .col-note {
    min-width:240px !important;
    width:280px;
    max-width:360px;
    white-space:normal !important;
    line-height:1.45;
}

.table-responsive .col-teacher {
    min-width:160px !important;
    width:180px;
    white-space:normal !important;
}

.table-responsive .col-name {
    min-width:180px !important;
    width:210px;
}

.table-responsive .col-action {
    min-width:140px !important;
    white-space:nowrap !important;
}

.quran-student-history th,
.quran-student-history td {
    min-width:125px;
}

.quran-student-history .col-date {
    min-width:105px !important;
}

.quran-student-history .col-note {
    min-width:260px !important;
}

.quran-student-history .col-teacher {
    min-width:170px !important;
}

.dataTables_wrapper {
    width:100%;
    max-width:100%;
    min-width:0;
    overflow-x:auto;
    -webkit-overflow-scrolling:touch;
}
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid #e5e7eb; }
th { background: #f9fafb; font-weight: bold; }
.table-matrix th { background-color: var(--primary); color: white; text-align: center; border: 1px solid #1e3a8a; }
.table-matrix td { border: 1px solid #d1d5db; vertical-align: top; }
.kelas-card { background: #f0fdf4; border-left: 4px solid var(--secondary); padding: 12px; margin-bottom: 10px; border-radius: 4px; box-shadow: 0 1px 3px rgba(0,0,0,0.1); }
.alert { padding: 15px; margin-bottom: 20px; border-radius: 4px; }
.alert.success { background: #d1fae5; color: #065f46; border: 1px solid #34d399; }
.alert.error { background: #fee2e2; color: #991b1b; border: 1px solid #f87171; }
.tab-content { display: none; }
.tab-content.active { display: block; }
.radio-absen { display: flex; gap: 10px; }
.radio-absen label { font-weight: normal; font-size: 0.85rem; cursor: pointer; display: flex; align-items: center; gap: 5px;}
#camera-container { width: 100%; max-width: 320px; margin: 0 auto 15px auto; border-radius: 8px; overflow: hidden; border: 2px solid #d1d5db; background: #000; }
.modal { display: none; position: fixed; z-index: 1000; left: 0; top: 0; width: 100%; height: 100%; overflow: auto; background-color: rgba(0,0,0,0.7); }
.modal-content { background-color: #fefefe; margin: 5% auto; padding: 20px; border: 1px solid #888; width: 90%; max-width: 450px; border-radius: 8px; text-align: center; }
.dataTables_wrapper { font-size: 0.9rem; margin-top:15px; }
.chat-container { height: 350px; overflow-y: auto; background: #e8ecef; border: 1px solid #bdc3c7; border-radius: 8px; padding: 15px; margin-bottom: 10px; display: flex; flex-direction: column; gap: 10px; }
.chat-msg { max-width: 80%; padding: 10px 15px; border-radius: 12px; font-size: 14px; line-height: 1.4; position:relative; box-shadow: 0 1px 2px rgba(0,0,0,0.1); }
.chat-msg.me { align-self: flex-end; background: #dcf8c6; border-bottom-right-radius: 0; }
.chat-msg.others { align-self: flex-start; background: #ffffff; border-bottom-left-radius: 0; }
.chat-header { font-size: 11px; font-weight: bold; margin-bottom: 5px; color: #2c3e50; display:flex; justify-content:space-between;}
.chat-time { font-size: 10px; color: #7f8c8d; text-align: right; margin-top: 5px; display:block; }
.form-chat-delete { position:absolute; top:-12px; right:-12px; opacity:0; transform:scale(0.8); transition:all 0.2s ease-in-out; margin:0; padding:0; z-index:10; }
.chat-msg:hover .form-chat-delete { opacity:1; transform:scale(1); }
.chat-delete { background:#ef4444; color:white; border:none; border-radius:50%; width:28px; height:28px; text-align:center; font-size:13px; line-height:28px; cursor:pointer; box-shadow:0 3px 6px rgba(0,0,0,0.3); padding:0; transition:0.2s; display:flex; justify-content:center; align-items:center; }
.chat-delete:hover { background:#b91c1c; }
.camera-box { text-align: center; margin-bottom: 15px; background: #fff; padding: 15px; border-radius: 8px; border: 2px dashed #bdc3c7; }
.camera-box video, .camera-box img { max-width: 100%; border-radius: 5px; border: 1px solid #ccc; }
.btn-download { background: #3498db; color: white; padding: 5px 10px; border-radius: 4px; text-decoration: none; font-size: 11px; display: inline-block; margin-top: 5px;}
.badge { display: inline-block; padding: 4px 8px; border-radius: 4px; font-size: 11px; font-weight: bold; color: white;}
@media (max-width: 768px) {
    body { flex-direction:column; max-width:100vw; overflow-x:hidden; }
    .sidebar { width:100%; display:none; }
    .sidebar.show { display:flex; }
    .header-mobile { display:flex; }
    .main-content { padding:12px; }
    .grid-2,
    .grid-3 { grid-template-columns:minmax(0,1fr); }
    .card { padding:14px; }
    .topbar { padding:12px 14px; }
    .tab-content form[style*="grid-template-columns"] {
        grid-template-columns:minmax(0,1fr) !important;
    }
    .tab-content div[style*="grid-template-columns"] {
        min-width:0 !important;
        max-width:100% !important;
    }
    .tab-content [style*="min-width:260px"],
    .tab-content [style*="min-width:220px"],
    .tab-content [style*="min-width:190px"],
    .tab-content [style*="min-width:180px"] {
        min-width:0 !important;
        width:100% !important;
    }

    /*
     * Tabel tetap mempertahankan lebar kolom yang nyaman.
     * Pada HP pengguna menggeser tabel secara horizontal.
     */
    .table-responsive {
        margin-left:0;
        margin-right:0;
    }

    .table-responsive > table {
        width:max-content;
        min-width:760px;
    }

    .table-responsive td {
        min-width:96px;
    }

    .table-responsive .col-note {
        min-width:240px !important;
    }

    .table-responsive .col-date {
        min-width:105px !important;
    }

    button,
    .btn-outline,
    .btn-success,
    .btn-warning,
    .btn-danger {
        max-width:100%;
        white-space:normal;
    }
}
.menu-category { padding: 15px 20px 5px 20px; font-size: 0.75rem; color: #9ca3af; text-transform: uppercase; font-weight: bold; letter-spacing: 1px; }
