/* ============================================================
   dashboard.css  ->  assets/css/dashboard.css
   Gaya halaman utama (index.html). Semua kelas berawalan "ga-"
   agar tidak bentrok dengan custom.css.
   Dimuat lewat front matter: css: /assets/css/dashboard.css
   ============================================================ */

/* Latar halaman abu-abu muda (hanya pada halaman yang memakai .ga-page) */
body:has(.ga-page) {
  background: #f3f5f9;
}

.ga-page {
  --ga-navy: #0f2a4a;
  --ga-blue: #1d5fa7;
  --ga-ink: #1f2937;
  --ga-muted: #6b7280;
  --ga-border: #e5e9f0;
  --ga-radius: 16px;
  padding-bottom: 2rem;
}

.ga-page :focus-visible {
  outline: 2px solid var(--ga-blue);
  outline-offset: 2px;
}

/* ---------- Header (hero) ---------- */

.ga-hero {
  background: linear-gradient(135deg, #0f2a4a 0%, #1d5fa7 100%);
  color: #fff;
  border-radius: var(--ga-radius);
  padding: 1.5rem 1.75rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 8px 24px rgba(15, 42, 74, .18);
}

.ga-hero-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  flex-wrap: wrap;
}

.ga-hero-text {
  min-width: 0;
  flex: 1 1 320px;
}

.ga-eyebrow {
  margin: 0 0 .25rem;
  font-size: .9rem;
  opacity: .9;
  overflow-wrap: anywhere;
}

.ga-title {
  margin: 0;
  font-size: clamp(1.35rem, 1.05rem + 1.3vw, 2rem);
  font-weight: 700;
  line-height: 1.2;
}

.ga-subtitle {
  margin: .35rem 0 0;
  font-size: .95rem;
  opacity: .8;
}

.ga-hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  margin-top: 1.25rem;
}

.ga-hero-actions .btn {
  background: rgba(255, 255, 255, .12);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, .35);
}

.ga-hero-actions .btn:hover,
.ga-hero-actions .btn:focus-visible {
  background: #fff;
  color: var(--ga-navy);
}

.ga-hero-actions .btn-logout:hover,
.ga-hero-actions .btn-logout:focus-visible {
  background: #dc3545;
  border-color: #dc3545;
  color: #fff;
}

/* ---------- Identitas user (chip) ---------- */

.ga-user {
  display: flex;
  align-items: center;
  gap: .75rem;
  max-width: 100%;
  padding: .4rem 1.1rem .4rem .4rem;
  background: rgba(255, 255, 255, .12);
  border: 1px solid rgba(255, 255, 255, .28);
  border-radius: 999px;
}

.ga-avatar {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: #fff;
  color: var(--ga-navy);
  font-weight: 700;
  letter-spacing: .02em;
}

.ga-user-text {
  min-width: 0;
}

.ga-user-name {
  font-weight: 600;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.ga-user-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .4rem;
  margin-top: .15rem;
  font-size: .78rem;
  opacity: .95;
}

.ga-role-badge {
  display: inline-block;
  padding: .1rem .55rem;
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 600;
  background: rgba(255, 255, 255, .22);
  color: #fff;
}

.ga-role-badge.ga-role-admin  { background: #ffc107; color: #3b2f00; }
.ga-role-badge.ga-role-viewer { background: #20c997; color: #05382b; }

/* ---------- Kartu umum ---------- */

.ga-card {
  background: #fff;
  border: 1px solid var(--ga-border);
  border-radius: var(--ga-radius);
  box-shadow: 0 1px 3px rgba(16, 24, 40, .06);
}

.ga-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: .75rem;
  padding: 1.1rem 1.25rem .35rem;
}

.ga-card-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  color: var(--ga-ink);
}

.ga-card-body {
  padding: 1rem 1.25rem 1.25rem;
}

.ga-tools {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .5rem;
}

.ga-search {
  width: 280px;
  max-width: 100%;
}

/* ---------- KPI ---------- */

.ga-kpi {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  padding: 1.25rem;
}

.ga-kpi-icon {
  flex: 0 0 auto;
  width: 52px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 14px;
  font-size: 1.3rem;
}

.ga-kpi-body {
  min-width: 0;
}

.ga-kpi-label {
  font-size: .75rem;
  font-weight: 600;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--ga-muted);
}

.ga-kpi-value {
  margin: .15rem 0;
  font-size: clamp(1.25rem, 1rem + 1vw, 1.65rem);
  font-weight: 700;
  line-height: 1.25;
  color: var(--ga-ink);
  overflow-wrap: anywhere;
}

.ga-kpi-note {
  font-size: .85rem;
  color: var(--ga-muted);
}

.ga-i-blue   { background: #e7f0fb; color: #1d5fa7; }
.ga-i-green  { background: #e6f5ec; color: #157347; }
.ga-i-amber  { background: #fff3d6; color: #b7791f; }
.ga-i-violet { background: #efe9fb; color: #6f42c1; }

/* ---------- Grafik ---------- */

.ga-chart {
  position: relative;
  height: 320px;
}

/* Kanvas tidak boleh melebihi kartu (bawaan 300px) pada layar sangat sempit */
.ga-chart canvas {
  max-width: 100%;
}

/* ---------- Akses Anda ---------- */

.ga-access-summary {
  margin: 0 0 1rem;
  padding: .75rem .9rem;
  font-size: .88rem;
  line-height: 1.45;
  color: #374151;
  background: #f5f8fc;
  border-left: 3px solid var(--ga-blue);
  border-radius: 8px;
}

.ga-access-item {
  display: flex;
  align-items: center;
  gap: .85rem;
  margin-bottom: .6rem;
  padding: .75rem .85rem;
  color: inherit;
  text-decoration: none;
  border: 1px solid var(--ga-border);
  border-radius: 12px;
  transition: border-color .15s, background-color .15s, transform .15s;
}

.ga-access-item:last-child {
  margin-bottom: 0;
}

.ga-access-item:hover,
.ga-access-item:focus-visible {
  border-color: var(--ga-blue);
  background: #f7faff;
  color: inherit;
}

.ga-access-icon {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
}

.ga-access-text {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.ga-access-title {
  font-weight: 600;
  color: var(--ga-ink);
}

.ga-access-desc {
  font-size: .8rem;
  color: var(--ga-muted);
}

.ga-level {
  flex: 0 0 auto;
  padding: .25rem .65rem;
  font-size: .72rem;
  font-weight: 600;
  white-space: nowrap;
  border-radius: 999px;
}

.ga-level-manage { background: #e6f5ec; color: #157347; }
.ga-level-view   { background: #eef1f5; color: #4b5563; }

/* ---------- Tabel ---------- */

.ga-section,
#section-kendaraan,
#section-aset {
  scroll-margin-top: 1rem;
}

.ga-table thead th {
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--ga-muted);
  background: #f8fafc;
  border-bottom: 1px solid var(--ga-border);
  white-space: nowrap;
}

.ga-table tbody td {
  border-color: #eef1f5;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 991.98px) {
  .ga-chart { height: 280px; }
}

@media (max-width: 767.98px) {

  .ga-hero {
    padding: 1.1rem 1rem;
    border-radius: 14px;
  }

  .ga-user {
    width: 100%;
    border-radius: 16px;
  }

  .ga-hero-actions .btn {
    flex: 1 1 auto;
  }

  .ga-hero-actions .btn-logout {
    margin-left: 0 !important;
  }

  .ga-card-head { padding: 1rem 1rem .25rem; }
  .ga-card-body { padding: .85rem 1rem 1rem; }

  .ga-tools { width: 100%; }
  .ga-search { width: 100%; flex: 1 1 100%; }

  .ga-chart { height: 250px; }

  .ga-access-desc { font-size: .78rem; }

  /* ---------- Tabel berubah menjadi daftar kartu ---------- */

  .ga-card .table-responsive { overflow: visible; }

  #fleetTable, #fleetTable tbody,
  #assetTable, #assetTable tbody {
    display: block;
    width: 100%;
  }

  #fleetTable thead,
  #assetTable thead {
    display: none;
  }

  #fleetTable tbody tr,
  #assetTable tbody tr {
    display: grid;
    align-items: center;
    gap: .2rem .75rem;
    margin-bottom: .75rem;
    padding: .85rem;
    background: #fff;
    border: 1px solid var(--ga-border);
    border-radius: 12px;
  }

  #fleetTable tbody tr { grid-template-columns: 56px 1fr; }
  #assetTable tbody tr { grid-template-columns: 56px 1fr; }

  #fleetTable tbody td,
  #assetTable tbody td {
    display: block;
    min-width: 0;
    padding: 0 !important;
    border: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    text-align: left !important;
  }

  /* Baris pesan (memuat / kosong / error) memenuhi lebar kartu */
  #fleetTable tbody td[colspan],
  #assetTable tbody td[colspan] {
    grid-column: 1 / -1;
    text-align: center !important;
    padding: .75rem 0 !important;
  }

  /* Label di depan nilai (diambil dari urutan kolom) */
  #fleetTable td:not([colspan]):nth-child(n+4)::before,
  #assetTable td:not([colspan]):nth-child(n+4)::before {
    display: inline-block;
    min-width: 88px;
    margin-right: .4rem;
    font-size: .74rem;
    font-weight: 600;
    color: var(--ga-muted);
  }

  /* ----- Kendaraan: Foto | Nopol | Jenis | Status | Peminjam | Aksi ----- */
  #fleetTable td:not([colspan]):nth-child(1) { grid-column: 1;      grid-row: 1 / span 2; }
  #fleetTable td:not([colspan]):nth-child(2) { grid-column: 2;      grid-row: 1; font-weight: 700; color: var(--ga-ink); }
  #fleetTable td:not([colspan]):nth-child(3) { grid-column: 2;      grid-row: 2; font-size: .85rem; color: var(--ga-muted); }
  #fleetTable td:not([colspan]):nth-child(4) { grid-column: 1 / -1; grid-row: 3; margin-top: .45rem; }
  #fleetTable td:not([colspan]):nth-child(5) { grid-column: 1 / -1; grid-row: 4; }
  #fleetTable td:not([colspan]):nth-child(6) { grid-column: 1 / -1; grid-row: 5; margin-top: .45rem; }

  #fleetTable td:not([colspan]):nth-child(4)::before { content: "Status"; }
  #fleetTable td:not([colspan]):nth-child(5)::before { content: "Peminjam"; }

  /* Karyawan: kolom aksi hanya berisi "-", tidak perlu ditampilkan */
  #fleetTable td.text-muted:nth-child(6) { display: none; }

  /* ----- Aset: Foto | Nama | Kategori | Stok | Nilai Buku | Keterangan | Aksi ----- */
  #assetTable td:not([colspan]):nth-child(1) { grid-column: 1;      grid-row: 1 / span 2; }
  #assetTable td:not([colspan]):nth-child(2) { grid-column: 2;      grid-row: 1; }
  #assetTable td:not([colspan]):nth-child(3) { grid-column: 2;      grid-row: 2; }
  #assetTable td:not([colspan]):nth-child(4) { grid-column: 1 / -1; grid-row: 3; margin-top: .45rem; }
  #assetTable td:not([colspan]):nth-child(5) { grid-column: 1 / -1; grid-row: 4; }
  #assetTable td:not([colspan]):nth-child(6) { grid-column: 1 / -1; grid-row: 5; }
  #assetTable td:not([colspan]):nth-child(7) { grid-column: 1 / -1; grid-row: 6; margin-top: .45rem; }

  #assetTable td:not([colspan]):nth-child(4)::before { content: "Stok"; }
  #assetTable td:not([colspan]):nth-child(5)::before { content: "Nilai Buku"; }
  #assetTable td:not([colspan]):nth-child(6)::before { content: "Keterangan"; }

  /* Tombol aksi memenuhi lebar kartu agar mudah disentuh */
  #assetTable td:last-child .btn-group { width: 100%; }
  #assetTable td:last-child .btn { flex: 1 1 0; padding-top: .45rem; padding-bottom: .45rem; }
  #fleetTable td:last-child .btn { padding: .45rem .9rem; }
}

@media (max-width: 575.98px) {
  .ga-kpi { padding: 1rem; }
  .ga-kpi-icon { width: 46px; height: 46px; font-size: 1.15rem; }

  /* Ikon di kiri, teks dan badge tingkat akses bertumpuk di kanan ikon */
  .ga-access-item {
    display: grid;
    grid-template-columns: 40px 1fr;
    align-items: start;
    column-gap: .85rem;
    row-gap: .35rem;
  }
  .ga-access-icon { grid-row: 1 / span 2; }
  .ga-access-text { grid-column: 2; }
  .ga-level { grid-column: 2; justify-self: start; }
}