/* =====================================================================
   CBT Thariq Bin Ziyad — identitas visual
   Palet resmi LPIT TBZ: hijau #008000 (primer), biru #003399 (sekunder),
   oranye #FF6600 (aksen SAJA — jangan jadi latar teks putih).
   Dimuat paling akhir di <head> lewat app/Views/Layout/_tbz_head.php
   ===================================================================== */

:root {
    --tbz-green-900: #004D00;
    --tbz-green-700: #006400;
    --tbz-green-500: #008000;
    --tbz-green-100: #E6F2E6;
    --tbz-green-050: #F3F9F3;
    --tbz-blue-900: #002266;
    --tbz-blue-500: #003399;
    --tbz-blue-100: #E6EBF5;
    --tbz-orange-700: #B34700;
    --tbz-orange-500: #FF6600;
    --tbz-orange-100: #FFF0E6;
    --tbz-neutral-900: #1A1A1A;
    --tbz-neutral-500: #6B7280;
    --tbz-neutral-100: #F5F5F5;

    --bs-primary: #008000;
    --bs-primary-rgb: 0, 128, 0;
    --bs-link-color: #006400;
    --bs-link-color-rgb: 0, 100, 0;
    --bs-link-hover-color: #004D00;
}

/* ---------- Komponen umum (panel admin & peserta) ---------- */
a {
    color: var(--tbz-green-700);
}

.form-control:hover {
    border-color: #99cc99;
    box-shadow: 0 3px 8px rgba(0, 128, 0, .12);
}

.form-control:focus,
.form-select:focus {
    border-color: var(--tbz-green-500) !important;
    box-shadow: 0 0 0 .2rem rgba(0, 128, 0, .18) !important;
}

.form-control:focus~label,
.form-group>label:has(+ .form-control:focus) {
    color: var(--tbz-green-700);
}

body.dark .form-control:hover {
    border-color: #4d994d;
}

body.dark .form-control:focus~label,
body.dark .form-group>label:has(+ .form-control:focus) {
    color: #66b366;
}

.btn-primary,
.btn-primary:focus {
    background-color: var(--tbz-green-500) !important;
    border-color: var(--tbz-green-500) !important;
    color: #fff !important;
}

.btn-primary:hover,
.btn-primary:active {
    background-color: var(--tbz-green-700) !important;
    border-color: var(--tbz-green-700) !important;
}

.btn-secondary,
.btn-secondary:focus {
    background-color: var(--tbz-blue-500) !important;
    border-color: var(--tbz-blue-500) !important;
    color: #fff !important;
}

.btn-secondary:hover {
    background-color: var(--tbz-blue-900) !important;
    border-color: var(--tbz-blue-900) !important;
}

.form-check-input:checked {
    background-color: var(--tbz-green-500);
    border-color: var(--tbz-green-500);
}

.page-item.active .page-link {
    background-color: var(--tbz-green-500);
    border-color: var(--tbz-green-500);
}

/* SweetAlert2 tombol konfirmasi */
.swal2-styled.swal2-confirm {
    background-color: var(--tbz-green-500) !important;
}

/* Garis aksen oranye kecil — penanda identitas TBZ */
.tbz-accent {
    display: inline-block;
    width: 44px;
    height: 4px;
    border-radius: 4px;
    background: var(--tbz-orange-500);
}

/* Footer kredit */
.tbz-credit {
    font-size: .78rem;
    color: var(--tbz-neutral-500);
}

.tbz-credit a {
    color: inherit;
    text-decoration: none;
}

/* ---------- Sidebar panel ---------- */
#sidebar .theme-brand .navbar-logo {
    width: 38px;
    height: 38px;
    object-fit: contain;
}

/* Nama aplikasi + nama unit: dua baris rapi, tidak terpotong oleh tombol « */
#sidebar .theme-brand .nav-logo {
    min-width: 0;
    flex: 1 1 auto;
    align-items: center;
}

#sidebar .theme-brand div.theme-text {
    min-width: 0;
    flex: 1 1 auto;
}

#sidebar .theme-brand div.theme-text a.tbz-brand {
    display: flex !important;
    flex-direction: column;
    justify-content: center;
    gap: 1px;
    padding: 0 0 0 10px !important;
    min-width: 0;
    white-space: normal;
    line-height: 1.15;
}

#sidebar .theme-brand .tbz-brand__nama {
    color: var(--tbz-green-900);
    font-size: 15px;
    font-weight: 800;
    letter-spacing: .1px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

#sidebar .theme-brand .tbz-brand__unit {
    color: var(--tbz-neutral-500);
    font-size: 11.5px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

body.dark #sidebar .theme-brand .tbz-brand__nama {
    color: #e6f2e6;
}

body.dark #sidebar .theme-brand .tbz-brand__unit {
    color: #9aa7a0;
}

/* Judul di header atas panel */
.tbz-header-judul {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--tbz-green-900);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 60vw;
}

.tbz-header-judul small {
    font-weight: 600;
    color: var(--tbz-neutral-500);
    margin-left: .35rem;
}

body.dark .tbz-header-judul {
    color: #e6f2e6;
}

/* Pratinjau logo unit di Pengaturan, meniru tampilan di halaman login */
.tbz-preview-logo {
    display: inline-flex;
    padding: 14px;
    border-radius: 16px;
    background: linear-gradient(135deg, var(--tbz-green-700), var(--tbz-green-500));
}

.tbz-preview-logo img {
    width: 88px;
    height: 88px;
    object-fit: contain;
    background: #fff;
    border-radius: 14px;
    padding: 8px;
    box-shadow: 0 6px 18px rgba(0, 0, 0, .18);
}

/* =====================================================================
   HALAMAN LOGIN (peserta & panel)
   ===================================================================== */
.tbz-auth-body {
    margin: 0;
    background: #fff;
}

.tbz-auth {
    font-family: 'Nunito', system-ui, -apple-system, 'Segoe UI', sans-serif;
    min-height: 100vh;
    margin: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    background: #fff;
    color: var(--tbz-neutral-900);
}

.tbz-auth__brand {
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 48px 56px;
    color: #fff;
    background:
        radial-gradient(1200px 600px at -10% 110%, rgba(255, 255, 255, .08), transparent 60%),
        linear-gradient(160deg, var(--tbz-green-500) 0%, var(--tbz-green-900) 100%);
}

/* Pola geometris islami halus (8 titik) — dekoratif */
.tbz-auth__brand::before {
    content: "";
    position: absolute;
    inset: 0;
    opacity: .07;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='80' height='80' viewBox='0 0 80 80'%3E%3Cg fill='none' stroke='%23fff' stroke-width='1.2'%3E%3Cpath d='M40 8l9.4 22.6L72 40l-22.6 9.4L40 72l-9.4-22.6L8 40l22.6-9.4z'/%3E%3Crect x='22' y='22' width='36' height='36' transform='rotate(45 40 40)'/%3E%3C/g%3E%3C/svg%3E");
    background-size: 80px 80px;
    pointer-events: none;
}

.tbz-auth__brand>* {
    position: relative;
}

.tbz-auth__org {
    display: flex;
    align-items: center;
    gap: 14px;
}

/* Logo resmi selalu di atas kartu putih (aturan brand: jangan di latar jenuh) */
.tbz-logo-chip {
    background: #fff;
    border-radius: 18px;
    padding: 10px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, .18);
    display: inline-flex;
}

.tbz-logo-chip img {
    width: 92px;
    height: 92px;
    object-fit: contain;
}

.tbz-auth__org small {
    display: block;
    opacity: .85;
    font-size: .82rem;
    letter-spacing: .4px;
    text-transform: uppercase;
}

.tbz-auth__org strong {
    font-size: 1.15rem;
    font-weight: 800;
    line-height: 1.2;
}

.tbz-auth__hero h1 {
    font-size: clamp(1.9rem, 3vw, 2.6rem);
    font-weight: 800;
    line-height: 1.15;
    margin: 18px 0 12px;
}

.tbz-auth__hero p {
    font-size: 1.02rem;
    max-width: 440px;
    opacity: .92;
    margin: 0;
}

.tbz-auth__points {
    list-style: none;
    padding: 0;
    margin: 26px 0 0;
    display: grid;
    gap: 10px;
}

.tbz-auth__points li {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    font-size: .95rem;
}

.tbz-auth__points li::before {
    content: "";
    flex: 0 0 8px;
    height: 8px;
    margin-top: 7px;
    border-radius: 2px;
    transform: rotate(45deg);
    background: var(--tbz-orange-500);
}

.tbz-auth__ayah {
    border-left: 3px solid var(--tbz-orange-500);
    padding: 4px 0 4px 14px;
    font-size: .92rem;
    opacity: .95;
}

.tbz-auth__ayah .ar {
    font-family: 'Amiri', 'Traditional Arabic', 'Scheherazade New', serif;
    font-size: 1.45rem;
    line-height: 1.6;
    direction: rtl;
    display: block;
}

.tbz-auth__panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 24px;
    background: linear-gradient(180deg, #fff 0%, var(--tbz-green-050) 100%);
}

.tbz-auth__card {
    width: 100%;
    max-width: 400px;
}

.tbz-auth__app {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 26px;
}

.tbz-auth__app img {
    width: 52px;
    height: 52px;
    object-fit: contain;
}

.tbz-auth__app b {
    display: block;
    font-size: 1.05rem;
    color: var(--tbz-green-900);
    font-weight: 800;
}

.tbz-auth__app span {
    font-size: .85rem;
    color: var(--tbz-neutral-500);
}

.tbz-auth__card h2 {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--tbz-green-900);
    margin: 0 0 6px;
}

.tbz-auth__card .lead-text {
    color: var(--tbz-neutral-500);
    margin: 10px 0 26px;
    font-size: .95rem;
}

.tbz-field {
    margin-bottom: 18px;
}

.tbz-field label {
    display: block;
    font-weight: 700;
    font-size: .88rem;
    margin-bottom: 6px;
    color: #374151;
}

.tbz-input {
    position: relative;
}

.tbz-input input {
    width: 100%;
    height: 50px;
    border-radius: 12px;
    border: 1.5px solid #d6dbe1;
    background: #fff;
    padding: 0 48px 0 16px;
    font-size: 1rem;
    color: var(--tbz-neutral-900);
    transition: border-color .2s, box-shadow .2s;
}

.tbz-input input:focus {
    outline: none;
    border-color: var(--tbz-green-500);
    box-shadow: 0 0 0 4px rgba(0, 128, 0, .14);
}

.tbz-input input.is-invalid {
    border-color: #dc3545;
}

.tbz-input .toggle-password {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    border: 0;
    background: transparent;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    color: var(--tbz-neutral-500);
    cursor: pointer;
    display: grid;
    place-items: center;
}

.tbz-input .toggle-password:hover,
.tbz-input .toggle-password:focus-visible {
    background: var(--tbz-green-100);
    color: var(--tbz-green-700);
    outline: none;
}

.tbz-field .invalid-feedback {
    font-size: .82rem;
}

.tbz-btn {
    width: 100%;
    height: 50px;
    border: 0;
    border-radius: 12px;
    background: var(--tbz-green-500);
    color: #fff;
    font-weight: 800;
    font-size: 1rem;
    letter-spacing: .3px;
    transition: background .2s, transform .1s, box-shadow .2s;
    box-shadow: 0 8px 20px rgba(0, 128, 0, .22);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.tbz-btn:hover {
    background: var(--tbz-green-700);
}

.tbz-btn:active {
    transform: translateY(1px);
}

.tbz-btn:disabled {
    opacity: .7;
    cursor: wait;
}

.tbz-btn .spinner-border {
    width: 1rem;
    height: 1rem;
    border-width: .15em;
}

.tbz-auth__note {
    margin-top: 22px;
    padding: 12px 14px;
    border-radius: 12px;
    background: var(--tbz-orange-100);
    color: #5a2a00;
    font-size: .85rem;
    display: flex;
    gap: 10px;
    align-items: flex-start;
}

.tbz-auth__note svg {
    flex: 0 0 18px;
    color: var(--tbz-orange-700);
    margin-top: 1px;
}

.tbz-auth__foot {
    margin-top: 28px;
    text-align: center;
}

/* Mobile / tablet — satu kolom, panel brand jadi header ringkas */
@media (max-width: 991.98px) {
    .tbz-auth {
        grid-template-columns: 1fr;
    }

    .tbz-auth__brand {
        padding: 22px 20px 26px;
        gap: 0;
    }

    .tbz-auth__hero,
    .tbz-auth__ayah {
        display: none;
    }

    .tbz-logo-chip {
        padding: 6px;
        border-radius: 14px;
    }

    .tbz-logo-chip img {
        width: 56px;
        height: 56px;
    }

    .tbz-auth__panel {
        justify-content: flex-start;
        padding: 28px 18px 36px;
    }

    .tbz-auth__app {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .tbz-btn {
        transition: none;
    }
}

/* =====================================================================
   PAPAN TULIS TANGAN (jawaban esai dengan Apple Pencil)
   ===================================================================== */
.tbz-papan {
    border: 1px solid #d1d5db;
    border-radius: 12px;
    background: #fff;
    overflow: hidden;
    /* Seluruh papan (termasuk toolbar) kebal seleksi teks & menu tekan-lama iOS */
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
}

.tbz-papan__alat,
.tbz-papan__kaki {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    background: var(--tbz-green-050);
}

.tbz-papan__alat {
    border-bottom: 1px solid #e5e7eb;
}

.tbz-papan__kaki {
    border-top: 1px solid #e5e7eb;
    justify-content: space-between;
}

.tbz-papan__sela {
    flex: 1 1 auto;
}

/* Target sentuh minimal 44px (pedoman Apple) */
.tbz-papan button {
    min-height: 44px;
    touch-action: manipulation;   /* tanpa jeda ketuk ganda / zoom */
    padding: 0 14px;
    border: 1px solid #d1d5db;
    border-radius: 10px;
    background: #fff;
    color: var(--tbz-neutral-900);
    font-size: .95rem;
}

.tbz-papan button.aktif {
    border-color: var(--tbz-green-500);
    background: var(--tbz-green-100);
    color: var(--tbz-green-900);
    font-weight: 700;
}

.tbz-papan__bidang {
    position: relative;
    width: 100%;
    /* garis bantu kertas; ukuran baris diatur JS mengikuti skala papan */
    background-color: #fff;
    background-image: linear-gradient(to bottom, transparent calc(100% - 1px), #dfe7ee calc(100% - 1px));
    background-size: 100% 48px;
    touch-action: none;
    overscroll-behavior: contain;
}

.tbz-papan__titik {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 6px;
    vertical-align: -1px;
}

.tbz-papan button.tbz-papan__bahaya {
    color: #b45309;
}

.tbz-papan canvas {
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    touch-action: none;           /* menulis tidak ikut menggulir halaman */
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;  /* cegah menu tekan-lama iOS */
    cursor: crosshair;
}

.tbz-papan canvas.mode-hapus {
    cursor: cell;
}

.tbz-papan__info {
    color: var(--tbz-neutral-500);
}

/* Tombol buka papan di soal esai */
.tbz-esai-tulis {
    min-height: 44px;
}

/* Tampilan coretan siswa di panel koreksi guru */
.tbz-coretan-guru {
    max-width: 100%;
    border: 1px solid #d1d5db;
    border-radius: 10px;
    background: #fff;
}

.tbz-papan__dasar {
    pointer-events: none;
}
