/* ============================================================
   UI CONSISTENCY LAYER — dimuat PALING AKHIR di semua layout.
   Tujuan: menyamakan tampilan komponen (tombol, form, tabel,
   kartu, judul seksi, header, navigasi) di seluruh halaman
   admin, wali kelas, guru BK, publik, login, dan scanner.
   Semua nilai memakai token dari app.css.
   ============================================================ */

/* ---------- 1. Tipografi konsisten ---------- */
h1, h2, h3, h4, h5, h6 {
  font-family: inherit;
  letter-spacing: -0.015em;
  line-height: 1.25;
}

/* Judul seksi: sebelumnya bervariasi (cyan / hijau / putih).
   Sekarang satu gaya: teks terang + garis aksen cyan. */
.section-title,
.card-title,
.card-head > h2,
.card-head > h3,
.card > h2:first-child,
.card > h3:first-child {
  font-size: 0.98rem;
  font-weight: 700;
  color: var(--txt);
  letter-spacing: 0.01em;
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

.section-title::before,
.card-title::before,
.card > h3:first-child::before {
  content: "";
  width: 3px;
  height: 1em;
  border-radius: var(--r-pill);
  background: linear-gradient(180deg, var(--neon-cyan), rgba(0, 243, 255, 0.15));
  flex: none;
}

.section-sub,
.card-sub {
  color: var(--txt-dim);
  font-size: 0.8rem;
  margin-top: 0.15rem;
}

/* ---------- 2. Tombol: ukuran & jarak seragam ---------- */
.btn {
  min-height: 40px;
  font-weight: 600;
  letter-spacing: 0.005em;
  white-space: nowrap;
}

.btn-sm { min-height: 34px; }
.btn-lg { min-height: 46px; padding-inline: 1.15rem; font-size: 0.95rem; }

/* Baris aksi/toolbar: jarak dan pembungkusan sama di semua halaman */
.toolbar,
.btn-group,
.card-head .actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-2);
}

/* Tombol aksi di dalam tabel selalu kecil dan rapat */
.tbl .actions,
.tbl td .btn-group {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  justify-content: flex-end;
}

.tbl .actions .btn {
  min-height: 32px;
  padding: 0.28rem 0.65rem;
  font-size: 0.76rem;
  border-radius: var(--r-sm);
}

/* Label yang berperan sebagai tombol (mis. Import Excel) */
label.btn { cursor: pointer; margin: 0; }

/* ---------- 3. Form: satu tinggi, satu radius ---------- */
.input,
input[type="text"],
input[type="search"],
input[type="number"],
input[type="email"],
input[type="tel"],
input[type="password"],
input[type="date"],
input[type="time"],
input[type="month"],
input[type="url"],
select,
textarea {
  width: 100%;
  min-height: 42px;
  padding: 0.55rem 0.8rem;
  background: var(--glass-bg);
  border: 1px solid var(--glass-brd);
  border-radius: var(--r-md);
  color: var(--txt);
  transition: var(--tr);
}

textarea { min-height: 96px; line-height: 1.55; }

.input:focus,
input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: rgba(0, 243, 255, 0.55);
  box-shadow: 0 0 0 3px rgba(0, 243, 255, 0.14);
}

select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 2.2rem;
  background-image: linear-gradient(45deg, transparent 50%, var(--txt-dim) 50%),
    linear-gradient(135deg, var(--txt-dim) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

select option { background: var(--bg-1); color: var(--txt); }

/* Label form seragam */
.form-label,
.field > label,
label.lbl {
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--txt-dim);
  margin-bottom: 0.35rem;
}

/* Input file: sebelumnya memakai tombol bawaan browser (abu-abu) */
input[type="file"] {
  width: 100%;
  min-height: 42px;
  padding: 0.4rem 0.6rem;
  background: var(--glass-bg);
  border: 1px dashed var(--glass-brd-2);
  border-radius: var(--r-md);
  color: var(--txt-dim);
  font-size: 0.82rem;
  cursor: pointer;
  transition: var(--tr);
}

input[type="file"]:hover { border-color: rgba(0, 243, 255, 0.45); color: var(--txt); }

input[type="file"]::file-selector-button {
  margin-right: 0.7rem;
  padding: 0.4rem 0.85rem;
  border: 1px solid rgba(0, 243, 255, 0.45);
  border-radius: var(--r-sm);
  background: rgba(0, 243, 255, 0.08);
  color: var(--neon-cyan);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--tr);
}

input[type="file"]::file-selector-button:hover {
  background: rgba(0, 243, 255, 0.16);
  box-shadow: var(--glow-cyan);
}

/* Input warna */
input[type="color"] {
  width: 100%;
  min-height: 42px;
  padding: 4px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-brd);
  border-radius: var(--r-md);
  cursor: pointer;
}

input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
input[type="color"]::-webkit-color-swatch { border: none; border-radius: 8px; }

/* Checkbox & radio */
input[type="checkbox"],
input[type="radio"] {
  width: 18px;
  height: 18px;
  min-height: 0;
  accent-color: var(--neon-cyan);
  cursor: pointer;
  flex: none;
}

.check-inline {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.85rem;
  cursor: pointer;
}

/* ---------- 4. Kartu & tabel ---------- */
.card { border-radius: var(--r-lg); }

.table-wrap {
  border-radius: var(--r-lg);
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

.tbl { width: 100%; }
.tbl thead th { white-space: nowrap; }
.tbl tbody td { vertical-align: middle; }

/* Badge status seragam tingginya */
.badge {
  min-height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* ---------- 5. Header & brand ---------- */
.app-header { min-height: var(--header-h); }

.hd-logo img,
.brand-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.brand-logo {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: var(--glass-bg);
  border: 1px solid var(--glass-brd);
  flex: none;
  overflow: hidden;
}

/* ---------- 6. Ruang bawah agar tidak tertutup navigasi mobile ---------- */
@media (max-width: 1023px) {
  .app-main,
  main.flex-1 {
    padding-bottom: calc(var(--bottomnav-h) + var(--safe-b) + 1.25rem);
  }
}

/* Tombol Install App tidak boleh menimpa bottom nav / tombol scan */
.pwa-install-btn,
#pwa-install {
  z-index: 60;
}

@media (max-width: 1023px) {
  .pwa-install-btn,
  #pwa-install {
    bottom: calc(var(--bottomnav-h) + var(--safe-b) + 1.5rem) !important;
  }
}

/* ---------- 7. Aksesibilitas & gerak ---------- */
:where(a, button, input, select, textarea, [tabindex]):focus-visible {
  outline: 2px solid rgba(0, 243, 255, 0.7);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---------- 8. Cetak ---------- */
@media print {
  .app-header,
  .sidebar,
  .bottom-nav,
  .pwa-install-btn,
  #pwa-install,
  #notif-panel,
  #notif-stack,
  .no-print {
    display: none !important;
  }

  body { background: #fff !important; color: #000 !important; }
  .card { border: 1px solid #ccc !important; box-shadow: none !important; }
}
