/* =========================================================
   Tampilan.css — lapisan tampilan Mankin 2026
   Dipakai bersama oleh Guru.html dan Bidang.html.
   Hanya mengatur tampilan; logika modul tidak disentuh.
   ========================================================= */
:root {
    --mk-sidebar: #0f1b3d;
    --mk-sidebar-2: #16244d;
    --mk-sidebar-line: rgba(148, 170, 220, .14);
    --mk-sidebar-text: #b7c4e3;
    --mk-accent: #2563eb;
    --mk-accent-soft: #e8efff;
    --mk-bg: #f4f6fb;
    --mk-surface: #ffffff;
    --mk-line: #e3e8f1;
    --mk-ink: #14203a;
    --mk-muted: #66748c;
    --mk-ok: #15935b;
    --mk-warn: #c77700;
    --mk-bad: #d13c3c;
    --mk-radius: 14px;
    --mk-ease: cubic-bezier(.2, .8, .2, 1);
    --mk-font: "Plus Jakarta Sans", "Inter", ui-sans-serif, system-ui, sans-serif;
}

body { font-family: var(--mk-font) !important; background: var(--mk-bg) !important; color: var(--mk-ink); -webkit-font-smoothing: antialiased; }
::-webkit-scrollbar-track { background: transparent !important; }
::-webkit-scrollbar-thumb { background: #c9d1df !important; border-radius: 99px !important; }

/* ---------------- Sidebar ---------------- */
#sidebar {
    width: 16rem; height: 100%; flex-shrink: 0; position: relative; z-index: 60;
    background: linear-gradient(180deg, var(--mk-sidebar) 0%, var(--mk-sidebar-2) 100%);
    color: #fff; display: flex; flex-direction: column; overflow: hidden;
    transition: width .32s var(--mk-ease), transform .32s var(--mk-ease), box-shadow .3s;
}
#sidebar .sidebar-content { width: 100%; height: 100%; display: flex; flex-direction: column; }
.mk-brand { height: 64px; display: flex; align-items: center; gap: 12px; padding: 0 18px; border-bottom: 1px solid var(--mk-sidebar-line); white-space: nowrap; flex-shrink: 0; }
.mk-brand-logo { width: 32px; height: 32px; border-radius: 9px; flex-shrink: 0; background: linear-gradient(135deg,#60a5fa,#2563eb); display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 15px; position: relative; overflow: hidden; }
.mk-brand-logo img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: var(--mk-sidebar); }
.mk-brand img.x { width: 32px; height: 32px; object-fit: contain; flex-shrink: 0; }
.mk-brand-text { display: flex; flex-direction: column; line-height: 1.1; transition: opacity .2s; }
.mk-brand-text b { font-size: 16px; font-weight: 800; letter-spacing: .06em; }
.mk-brand-text small { font-size: 11px; color: var(--mk-sidebar-text); font-weight: 500; margin-top: 3px; }

.mk-nav { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 12px 10px 16px; display: flex; flex-direction: column; gap: 14px; }
.mk-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15) !important; }
.mk-group { display: flex; flex-direction: column; gap: 2px; }
.mk-group-label { font-size: 10.5px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: #7f8fb5; padding: 0 12px 4px; white-space: nowrap; transition: opacity .2s; }
.mk-item {
    display: flex !important; align-items: center; gap: 12px; position: relative;
    padding: 9px 12px !important; border: 0 !important; border-radius: 10px;
    color: var(--mk-sidebar-text) !important; font-size: 13.5px; font-weight: 500; white-space: nowrap; text-decoration: none;
    transition: background-color .18s, color .18s, transform .18s;
}
.mk-item i { width: 18px; text-align: center; font-size: 14px; flex-shrink: 0; transition: transform .25s var(--mk-ease); }
.mk-item span { transition: opacity .2s; overflow: hidden; text-overflow: ellipsis; }
.mk-item:hover { background: rgba(255,255,255,.07); color: #fff !important; }
.mk-item:hover i { transform: scale(1.12); }
.mk-item:focus-visible { outline: 2px solid #8fb0ff; outline-offset: 1px; }
/* Kelas aktif dipasang oleh showView() bawaan */
.mk-item.bg-brand-800 { background: rgba(96, 140, 255, .18) !important; color: #fff !important; font-weight: 600; }
.mk-item.bg-brand-800::before { content: ""; position: absolute; left: -10px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: #7aa2ff; }
.mk-item.bg-brand-800 i { color: #9dbbff; }

.mk-user { padding: 14px; border-top: 1px solid var(--mk-sidebar-line); display: flex; align-items: center; gap: 10px; white-space: nowrap; flex-shrink: 0; }
.mk-avatar { width: 34px; height: 34px; border-radius: 50%; background: linear-gradient(135deg, #60a5fa, #2563eb); display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 13px; flex-shrink: 0; }
.mk-user-text { flex: 1; min-width: 0; transition: opacity .2s; }
.mk-user-text p { margin: 0; font-size: 12.5px; font-weight: 700; }
.mk-user-text small { font-size: 11px; color: var(--mk-sidebar-text); }
.mk-logout { color: #ff8a8a; width: 32px; height: 32px; border-radius: 8px; display: flex; align-items: center; justify-content: center; transition: background .2s; flex-shrink: 0; }
.mk-logout:hover { background: rgba(255,255,255,.08); }

/* Desktop: sidebar diciutkan menjadi deretan ikon */
@media (min-width: 768px) {
    #sidebar.sidebar-closed { width: 4.75rem !important; opacity: 1 !important; pointer-events: auto !important; }
    #sidebar.sidebar-closed .mk-brand { padding: 0 22px; }
    #sidebar.sidebar-closed .mk-brand-text,
    #sidebar.sidebar-closed .mk-group-label,
    #sidebar.sidebar-closed .mk-item span,
    #sidebar.sidebar-closed .mk-user-text { opacity: 0; pointer-events: none; }
    #sidebar.sidebar-closed .mk-group-label { height: 0; padding: 0; overflow: hidden; }
    #sidebar.sidebar-closed .mk-group { padding-top: 6px; border-top: 1px solid var(--mk-sidebar-line); }
    #sidebar.sidebar-closed .mk-group:first-child { border-top: 0; }
    #sidebar.sidebar-closed .mk-item { justify-content: flex-start; padding: 10px 17px !important; }
    #sidebar.sidebar-closed .mk-user { padding: 14px 18px; }
    #sidebar.sidebar-closed .mk-logout { display: none; }
    .mk-only-mobile { display: none !important; }
}

/* HP: sidebar menjadi laci yang muncul dari kiri */
@media (max-width: 767px) {
    #sidebar { position: fixed !important; top: 0; left: 0; bottom: 0; width: min(18rem, 86vw) !important; transform: translateX(-104%); opacity: 1 !important; pointer-events: auto !important; }
    #sidebar.sidebar-open { transform: none; box-shadow: 0 0 60px rgba(8, 15, 35, .45); }
    .mk-only-desktop { display: none !important; }
}
#mk-backdrop { position: fixed; inset: 0; z-index: 55; background: rgba(10, 18, 40, .45); backdrop-filter: blur(2px); opacity: 0; pointer-events: none; transition: opacity .3s; }
#mk-backdrop.show { opacity: 1; pointer-events: auto; }
@media (min-width: 768px) { #mk-backdrop { display: none; } }

/* ---------------- Topbar ---------------- */
main { background: var(--mk-bg) !important; min-width: 0; }
.mk-topbar {
    height: 64px; flex-shrink: 0; display: flex; align-items: center; gap: 12px; padding: 0 20px;
    background: rgba(255,255,255,.86); backdrop-filter: saturate(1.4) blur(10px);
    border-bottom: 1px solid var(--mk-line); position: relative; z-index: 20;
}
.mk-icon-btn {
    width: 38px; height: 38px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center;
    color: var(--mk-muted); border: 1px solid var(--mk-line); background: var(--mk-surface); flex-shrink: 0;
    transition: color .18s, border-color .18s, background .18s, transform .12s;
}
.mk-icon-btn:hover { color: var(--mk-accent); border-color: #c6d4f5; }
.mk-icon-btn:active { transform: scale(.94); }
#floating-toggle { transform: none !important; }
#floating-icon.fa-star::before { content: "\f03b"; }
#floating-icon.fa-bars-staggered::before { content: "\f03c"; }
.mk-title { min-width: 0; flex: 1; display: flex; flex-direction: column; line-height: 1.15; }
.mk-crumb { font-size: 11px; color: var(--mk-muted); font-weight: 600; letter-spacing: .02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#mobile-header-title { margin: 0; font-size: 17px; font-weight: 800; color: var(--mk-ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: -.01em; }
.mk-search {
    display: flex; align-items: center; gap: 10px; height: 38px; width: 260px; padding: 0 12px;
    border: 1px solid var(--mk-line); border-radius: 10px; background: var(--mk-bg); color: var(--mk-muted); font-size: 13px;
    transition: border-color .18s, background .18s;
}
.mk-search:hover { border-color: #c6d4f5; background: #fff; }
.mk-search kbd { margin-left: auto; font: 600 10.5px var(--mk-font); border: 1px solid var(--mk-line); background: #fff; border-radius: 6px; padding: 2px 6px; }
@media (max-width: 900px) { .mk-search { width: auto; } .mk-search span, .mk-search kbd { display: none; } .mk-search { width: 38px; justify-content: center; padding: 0; } }
@media (max-width: 767px) { .mk-topbar { height: 58px; padding: 0 12px; gap: 8px; } #mobile-header-title { font-size: 16px; } }

/* Konteks Bidang */
#bidang-context-bar { background: var(--mk-surface) !important; border-color: var(--mk-line) !important; box-shadow: none !important; padding-top: 8px !important; padding-bottom: 8px !important; }

/* ---------------- Area konten ---------------- */
main > div.flex-1 { padding: 20px !important; scroll-behavior: smooth; }
@media (max-width: 767px) {
    main > div.flex-1 { padding: 12px 12px calc(88px + env(safe-area-inset-bottom, 0px)) !important; }
    #toast-container { bottom: calc(84px + env(safe-area-inset-bottom, 0px)) !important; left: 12px; right: 12px !important; }
}

/* Transisi pindah halaman */
@keyframes mk-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.view-section.mk-enter { animation: mk-in .34s var(--mk-ease) both; }

/* Kartu modul: sudut, garis, dan bayangan seragam */
.view-section > .bg-white.rounded-xl,
.view-section > div > .bg-white.rounded-xl.border,
.view-section .bg-white.rounded-xl.shadow-sm {
    border-radius: var(--mk-radius) !important; border-color: var(--mk-line) !important;
    box-shadow: 0 1px 2px rgba(16, 24, 48, .04), 0 6px 24px -12px rgba(16, 24, 48, .12) !important;
}
.view-section h2.text-lg { font-size: 18px; font-weight: 800; letter-spacing: -.01em; }
/* Teks yang terlalu kecil dibuat sedikit lebih besar agar terbaca */
main .text-\[10px\] { font-size: 11px !important; }
main .text-\[11px\] { font-size: 12px !important; }

/* Tombol: umpan balik saat ditekan */
main button { transition: background-color .18s, color .18s, border-color .18s, box-shadow .18s, transform .12s; }
main button:not(:disabled):active { transform: scale(.97); }
main button:focus-visible, main a:focus-visible { outline: 2px solid var(--mk-accent); outline-offset: 2px; }

/* Isian form */
main input:not([type=checkbox]):not([type=radio]):not([type=file]):not([type=color]),
main select, main textarea { transition: border-color .18s, box-shadow .18s; }
main input:focus, main select:focus, main textarea:focus { box-shadow: 0 0 0 3px rgba(37, 99, 235, .15) !important; border-color: var(--mk-accent) !important; }
@media (max-width: 767px) {
    /* 16px mencegah HP memperbesar layar otomatis saat mengetik */
    main input:not([type=checkbox]):not([type=radio]):not(table input),
    main select:not(table select), main textarea { font-size: 16px !important; min-height: 42px; }
    main textarea { min-height: 0; }
    .view-section h2.text-lg { font-size: 17px; }
}

/* Tabel: baris disorot saat disentuh, kepala tabel menempel */
main table tbody tr { transition: background-color .15s; }
main table tbody tr:hover { background-color: #f6f9ff; }

/* ---------------- Navigasi bawah (HP) ---------------- */
#mk-bottomnav { display: none; }
@media (max-width: 767px) {
    #mk-bottomnav {
        display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
        background: rgba(255,255,255,.94); backdrop-filter: blur(12px); border-top: 1px solid var(--mk-line);
        padding: 6px 4px calc(6px + env(safe-area-inset-bottom, 0px));
    }
    #mk-bottomnav button { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 2px; font-size: 10.5px; font-weight: 600; color: var(--mk-muted); border-radius: 12px; transition: color .18s; }
    #mk-bottomnav button i { font-size: 17px; height: 22px; display: flex; align-items: center; transition: transform .25s var(--mk-ease); }
    #mk-bottomnav button.on { color: var(--mk-accent); }
    #mk-bottomnav button.on i { transform: translateY(-2px); }
    #mk-bottomnav button span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
}

/* ---------------- Pencarian cepat (Ctrl K) ---------------- */
#mk-palette { position: fixed; inset: 0; z-index: 300; display: flex; align-items: flex-start; justify-content: center; padding: 12vh 16px 16px; background: rgba(10, 18, 40, .4); backdrop-filter: blur(3px); opacity: 0; pointer-events: none; transition: opacity .2s; }
#mk-palette.show { opacity: 1; pointer-events: auto; }
.mk-pal-box { width: 100%; max-width: 560px; background: #fff; border-radius: 16px; box-shadow: 0 30px 80px -20px rgba(10, 18, 40, .45); overflow: hidden; transform: translateY(-8px) scale(.98); transition: transform .25s var(--mk-ease); }
#mk-palette.show .mk-pal-box { transform: none; }
.mk-pal-input { display: flex; align-items: center; gap: 12px; padding: 0 18px; border-bottom: 1px solid var(--mk-line); color: var(--mk-muted); }
.mk-pal-input input { flex: 1; height: 56px; border: 0 !important; outline: none; font-size: 16px; font-family: var(--mk-font); color: var(--mk-ink); background: transparent; box-shadow: none !important; }
.mk-pal-list { max-height: 52vh; overflow-y: auto; padding: 8px; }
.mk-pal-item { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; padding: 10px 12px; border-radius: 10px; font-size: 14px; color: var(--mk-ink); }
.mk-pal-item i { width: 30px; height: 30px; border-radius: 8px; background: var(--mk-bg); color: var(--mk-accent); display: flex; align-items: center; justify-content: center; font-size: 13px; flex-shrink: 0; }
.mk-pal-item small { margin-left: auto; color: var(--mk-muted); font-size: 11.5px; }
.mk-pal-item.sel { background: var(--mk-accent-soft); }
.mk-pal-empty { padding: 28px; text-align: center; color: var(--mk-muted); font-size: 14px; }

/* ---------------- Beranda ---------------- */
.mk-home { max-width: 1180px; margin: 0 auto; display: flex; flex-direction: column; gap: 20px; }
.mk-hero {
    position: relative; overflow: hidden; border-radius: 20px; padding: 26px 28px; color: #fff;
    background: radial-gradient(120% 140% at 100% 0%, #3b6cf0 0%, #1d3a9a 45%, #0f1b3d 100%);
    display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 18px;
}
.mk-hero::after { content: ""; position: absolute; right: -60px; bottom: -90px; width: 260px; height: 260px; border-radius: 50%; border: 40px solid rgba(255,255,255,.06); pointer-events: none; }
.mk-hero-eyebrow { font-size: 12px; font-weight: 600; color: #b9cbff; letter-spacing: .04em; }
.mk-hero h2 { margin: 4px 0 6px; font-size: clamp(20px, 3vw, 26px); font-weight: 800; letter-spacing: -.02em; }
.mk-hero p { margin: 0; color: #d4defa; font-size: 13.5px; }
.mk-hero-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.mk-chip { font-size: 12px; font-weight: 600; padding: 5px 11px; border-radius: 99px; background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.16); }
.mk-hero-btn { position: relative; z-index: 1; display: inline-flex; align-items: center; gap: 8px; background: #fff; color: #1d3a9a; font-weight: 700; font-size: 13.5px; padding: 11px 16px; border-radius: 12px; box-shadow: 0 10px 24px -10px rgba(0,0,0,.4); transition: transform .2s var(--mk-ease); }
.mk-hero-btn:hover { transform: translateY(-2px); }

.mk-stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
@media (min-width: 1100px) { .mk-stats { grid-template-columns: repeat(var(--n, 4), minmax(0, 1fr)); } }
.mk-stat { background: var(--mk-surface); border: 1px solid var(--mk-line); border-radius: var(--mk-radius); padding: 16px 18px; display: flex; align-items: center; gap: 14px; transition: transform .2s var(--mk-ease), box-shadow .2s; }
.mk-stat:hover { transform: translateY(-2px); box-shadow: 0 12px 28px -16px rgba(16,24,48,.25); }
.mk-stat-ic { width: 44px; height: 44px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 17px; flex-shrink: 0; }
.mk-stat-n { font-size: 24px; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.mk-stat-l { font-size: 12.5px; color: var(--mk-muted); margin-top: 4px; font-weight: 500; }

.mk-section-h { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.mk-section-h h3 { margin: 0; font-size: 15px; font-weight: 800; }
.mk-section-h span { font-size: 12px; color: var(--mk-muted); }
.mk-groups { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 14px; }
.mk-gcard { background: var(--mk-surface); border: 1px solid var(--mk-line); border-radius: var(--mk-radius); padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.mk-gcard-h { font-size: 11px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: var(--mk-muted); }
.mk-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 8px; }
.mk-tile { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 11px; border: 1px solid transparent; background: var(--mk-bg); font-size: 13px; font-weight: 600; color: var(--mk-ink); text-align: left; transition: border-color .18s, background .18s, transform .18s var(--mk-ease); }
.mk-tile i { width: 30px; height: 30px; border-radius: 9px; background: #fff; color: var(--mk-accent); display: flex; align-items: center; justify-content: center; font-size: 13px; flex-shrink: 0; box-shadow: 0 1px 2px rgba(16,24,48,.06); }
.mk-tile:hover { background: #fff; border-color: #c6d4f5; transform: translateY(-2px); }
.mk-tile span { min-width: 0; line-height: 1.3; overflow-wrap: anywhere; }

@media (max-width: 767px) {
    .mk-hero { padding: 20px; border-radius: 16px; }
    .mk-stats { grid-template-columns: 1fr 1fr; gap: 10px; }
    .mk-stat { padding: 12px; gap: 10px; flex-direction: column; align-items: flex-start; }
    .mk-stat-ic { width: 36px; height: 36px; font-size: 15px; }
    .mk-stat-n { font-size: 21px; }
    .mk-groups { grid-template-columns: 1fr; }
    .mk-tiles { grid-template-columns: 1fr 1fr; }
}

/* Masuk bertahap untuk elemen Beranda */
.mk-stagger > * { animation: mk-in .45s var(--mk-ease) both; }
.mk-stagger > *:nth-child(2) { animation-delay: .05s; }
.mk-stagger > *:nth-child(3) { animation-delay: .1s; }
.mk-stagger > *:nth-child(4) { animation-delay: .15s; }
.mk-stagger > *:nth-child(5) { animation-delay: .2s; }
.mk-stagger > *:nth-child(6) { animation-delay: .25s; }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; animation-delay: 0s !important; transition-duration: .01ms !important; }
}

/* ---------------- Panel Capaian Pembelajaran (menu TP) ---------------- */
.mk-cp { margin: 14px 16px 0; border: 1px solid #cfe0ff; background: #f5f9ff; border-radius: 12px; overflow: hidden; }
.mk-cp summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 11px 14px; font-size: 13.5px; font-weight: 700; color: #1d3a9a; }
.mk-cp summary::-webkit-details-marker { display: none; }
.mk-cp summary::after { content: "\f078"; font-family: "Font Awesome 6 Free"; font-weight: 900; font-size: 11px; margin-left: auto; transition: transform .2s; }
.mk-cp[open] summary::after { transform: rotate(180deg); }
.mk-cp summary small { font-weight: 600; color: var(--mk-muted); font-size: 12px; }
.mk-cp-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; padding: 0 14px 12px; }
.mk-cp-item { background: #fff; border: 1px solid var(--mk-line); border-radius: 10px; padding: 10px 12px; }
.mk-cp-item b { display: block; font-size: 12.5px; color: var(--mk-ink); margin-bottom: 4px; }
.mk-cp-item p { margin: 0; font-size: 12.5px; line-height: 1.55; color: #3c4a63; }
.mk-cp-src { margin: 0; padding: 0 14px 12px; font-size: 11.5px; color: var(--mk-muted); }
@media (max-width: 767px) { .mk-cp-grid { grid-template-columns: 1fr; } .mk-cp { margin: 12px 0 0; } }

/* Buku Nilai: angka 3 digit (100) tidak terpotong */
#view-nilai input[type=number] { min-width: 2.6rem; padding-left: 2px !important; padding-right: 2px !important; -moz-appearance: textfield; appearance: textfield; }
#view-nilai input[type=number]::-webkit-outer-spin-button,
#view-nilai input[type=number]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

/* Buku Nilai: deskripsi hasil AI */
#view-nilai td.mk-desk-ai { background: #faf5ff !important; color: #3b2a5a; }
