/* =========================
   GLOBAL RESET & BASE
========================= */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: "Segoe UI", Tahoma, sans-serif;
  background: #eef3ff;
  padding: 20px;
  color: #1a1a1a;
}

/* =========================
   WRAPPER / CARD
========================= */
.wrapper {
  background: #fff;
  border-radius: 16px;
  padding: 20px;
  max-width: 1000px;
  margin: 20px auto;
  box-shadow: 0 4px 20px rgba(0,0,0,0.2);
}

h1 {
  text-align: center;
  color: #1a3c7c;
  margin-bottom: 15px;
}

p {
  margin: 10px 0;
}

/* =========================
   FORM ELEMENTS
========================= */
label {
  font-weight: bold;
  display: block;
  margin-top: 10px;
}

input[type=text],
input[type=number],
input[type=file],
select,
textarea {
  width: 100%;
  padding: 10px;
  margin-top: 6px;
  border-radius: 8px;
  border: 1px solid #ccc;
  font-size: 15px;
}

textarea {
  min-height: 90px;
  resize: vertical;
}

/* =========================
   CANVAS
========================= */
canvas {
  display: block;
  margin: 10px auto;
  max-width: 100%;
  border: 1px solid #ccc;
  border-radius: 8px;
}

/* =========================
   BUTTONS
========================= */
button {
  font-weight: bold;
  cursor: pointer;
  transition: background 0.2s, transform 0.2s;
  border: none;
  border-radius: 10px;
  padding: 12px 16px;
  margin-top: 10px;
  width: 100%;
  font-size: 0.95rem;
  background: #1a73e8;
  color: #fff;
}

button:hover {
  background: #1669c1;
}

.btn-danger {
  background: #e53935;
}
.btn-danger:hover {
  background: #c62828;
}

.btn-green {
  background: #34a853;
}
.btn-green:hover {
  background: #2c8e46;
}

.btn-purple {
  background: #6c63ff;
}
.btn-purple:hover {
  background: #5146d9;
}

/* =========================
   DASHBOARD NAV GRID
========================= */
.nav-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 20px;
  width: 100%;
  max-width: 1000px;
  margin: 30px auto;
}

.card {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  padding: 20px;
  text-align: center;
  transition: transform 0.2s;
  cursor: pointer;
}
.card:hover {
  transform: translateY(-5px);
}

/* =========================
   TABLE (admin panel)
========================= */
table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 15px;
}

th, td {
  padding: 8px;
  border-bottom: 1px solid #ddd;
  text-align: left;
  font-size: 0.9rem;
}

th {
  background: #f5f5f5;
}

/* =========================
   RESPONSIVE
========================= */
@media (max-width: 600px) {
  .wrapper {
    padding: 15px;
    border-radius: 10px;
  }
  h1 { font-size: 1.2rem; }
  button {
    font-size: 0.85rem;
    padding: 10px;
  }

  /* 🔹 Perbaikan tabel: tetap tabel, bisa scroll horizontal */
  table {
    display: block;
    width: 100%;
    overflow-x: auto;
    border: 1px solid #ddd;
  }
  table th, table td {
    padding: 6px;
    font-size: 0.85rem;
    white-space: nowrap; /* biar tidak patah ke bawah */
  }
}

/* =========================
   MODE BUTTON KANAN - KIRI
========================= */
.mode-select {
  display: flex;
  justify-content: space-between;
  margin: 20px 0;
}

.mode-select input[type="radio"] { display: none; }

.mode-select label {
  flex: 1;
  text-align: center;
  padding: 12px 0;
  margin: 0 4px;
  border: 2px solid var(--border);
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  background: var(--card);
  color: var(--text);
  transition: all 0.2s ease;
}

.mode-select input[type="radio"]:checked + label {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* =========================
   SALDO USER
========================= */
#saldoUser {
  text-align: center;
  font-size: 1rem;
  font-weight: bold;
  margin-bottom: 15px;
  color: #1a3c7c;
}

/* =========================
   THEME (LIGHT / DARK)
========================= */
:root {
  --bg: #ffffff;
  --text: #0f172a;
  --muted: #475569;
  --card: #ffffff;
  --border: #e5e7eb;
  --accent: #2563eb;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1220;
    --text: #e5e7eb;
    --muted: #94a3b8;
    --card: #0f172a;
    --border: #1f2937;
    --accent: #60a5fa;
  }
}

html, body {
  background: var(--bg);
  color: var(--text);
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.input, input, textarea, select {
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn {
  background: var(--accent);
  color: #fff;
  border-radius: 12px;
  padding: 10px 14px;
  font-weight: 600;
  cursor: pointer;
}
.btn:disabled { opacity: .6; cursor: not-allowed; }

*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: var(--bg); }
*::-webkit-scrollbar-thumb { background: var(--border); border-radius: 999px; }

* { transition: background-color .2s ease, color .2s ease, border-color .2s ease; }

/* =========================
   PRODUK (Judul & Deskripsi)
========================= */
.card h2 {
  font-size: 1.1rem;      
  font-weight: 600;       
  color: #1a3c7c;
  text-align: center;
  line-height: 1.4;
  margin-bottom: 8px;
  letter-spacing: .2px;
  overflow-wrap: anywhere;
  hyphens: auto;
  text-wrap: balance;
}

.card p {
  font-size: 0.9rem;
  color: #555;
  line-height: 1.5;
  margin-bottom: 12px;
  text-align: center;
}

@media (max-width: 600px) {
  .card h2 { font-size: 1rem; }
  .card p  { font-size: 0.85rem; }
}

/* =========================
   RESPONSIVE PRODUK TABLE
   (khusus tampilan mobile)
========================= */
@media (max-width: 600px) {
  #produkTable thead {
    display: none; /* sembunyikan header */
  }
  #produkTable, 
  #produkTable tbody, 
  #produkTable tr, 
  #produkTable td {
    display: block;
    width: 100%;
  }
  #produkTable tr {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 12px;
    margin-bottom: 15px;
    padding: 12px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.08);
  }
  #produkTable td {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    padding: 6px 0;
  }
  #produkTable td::before {
    content: attr(data-label); /* label sesuai header */
    font-weight: bold;
    color: #555;
    margin-bottom: 4px;
    font-size: 0.85rem;
  }

  /* Biar input/textarea full width */
  #produkTable input,
  #produkTable select,
  #produkTable textarea {
    width: 100%;
    font-size: 0.9rem;
    padding: 6px;
    border-radius: 6px;
    border: 1px solid #ccc;
  }

  /* Tombol lebih kecil biar pas */
  #produkTable .btn-green,
  #produkTable .btn-danger {
    width: 100%;
    margin-top: 8px;
    font-size: 0.85rem;
    padding: 8px;
  }
}

/* =========================
   RESPONSIVE USERS TABLE
   (khusus tampilan mobile)
========================= */
@media (max-width: 600px) {
  #usersTable thead {
    display: none; /* sembunyikan header */
  }
  #usersTable,
  #usersTable tbody,
  #usersTable tr,
  #usersTable td {
    display: block;
    width: 100%;
  }
  #usersTable tr {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 12px;
    margin-bottom: 15px;
    padding: 12px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.08);
  }
  #usersTable td {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    padding: 6px 0;
  }
  #usersTable td::before {
    content: attr(data-label); /* label sesuai header */
    font-weight: bold;
    color: #555;
    margin-bottom: 4px;
    font-size: 0.85rem;
  }

  /* Tombol lebih kecil biar pas */
  #usersTable .btn-green,
  #usersTable .btn-danger {
    width: 100%;
    margin-top: 8px;
    font-size: 0.85rem;
    padding: 8px;
  }
}

/* =========================
   PRODUK: 2 kolom di mobile
========================= */
@media (max-width: 600px) {
  #produkContainer.nav-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 12px;
  }

  #produkContainer .card {
    padding: 10px;
  }

  #produkContainer .card h2 {
    font-size: 0.9rem;
    margin-bottom: 6px;
  }

  #produkContainer .card p {
    font-size: 0.8rem;
    margin-bottom: 8px;
  }

  #produkContainer .card button {
    font-size: 0.75rem;
    padding: 6px 8px;
    border-radius: 6px;
  }
}
/* Ratakan isi produk agar rapi */
#produkContainer .card {
  display: flex;
  flex-direction: column;
}

#produkContainer .card h2 {
  margin-bottom: 6px;
}

#produkContainer .card p {
  flex-grow: 1;         /* isi ruang kosong agar tinggi seragam */
  margin-bottom: 8px;   /* jarak sebelum tombol */
}

#produkContainer .card button {
  margin-top: auto;     /* dorong tombol ke bawah */
  align-self: center;   /* tetap center */
}
