/* Reset & Base Styles */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 100%;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: "Segoe UI", sans-serif;
  font-size: 1rem;
  line-height: 1.6;
  background-color: var(--bg, #f5f7fa);
  color: var(--text, #333);
  max-width: 100%;
  overflow-x: hidden;
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* Layout Utama */
main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1rem;
}

.layout {
  display: flex;
  flex-wrap: wrap;
  gap: 2rem;
}

h1 {
  text-align: center;
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 2rem;
  color: var(--heading, #222);
  line-height: 1.3;
}

/* Panel Konfigurasi */
.config-panel {
  flex: 1 1 300px;
  background-color: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  transition: background-color 0.3s ease, color 0.3s ease;
}

.config-panel form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.config-panel label {
  font-weight: 600;
  color: var(--label);
  margin-bottom: 0.25rem;
}

.config-panel input,
.config-panel select {
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background-color: var(--panel-bg);
  color: var(--text);
  transition: background-color 0.3s ease, color 0.3s ease;
}

.birth-range {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
}

.birth-range input[type="date"] {
  flex: 1;
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background-color: var(--panel-bg);
  color: var(--text);
  font-size: 1rem;
  transition: background-color 0.3s ease, color 0.3s ease;
}

.to-text {
  white-space: nowrap;
  font-weight: normal;
  color: var(--label);
  font-size: 0.95rem;
}
button {
  padding: 0.6rem 1rem;
  background-color: var(--accent);
  color: white;
  font-weight: 600;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 1rem;
  transition: background-color 0.3s ease, color 0.3s ease;
}

button:hover {
  background-color: var(--hover-accent);
}

/* Tombol khusus: Reset Data */
#reset-data {
  background-color: #c06565;
}

#reset-data:hover {
  background-color: #a24f4f;
}

/* Tombol Generate Mobile */
.generate-mobile-btn {
  display: none;
  margin: 1rem auto 2rem auto;
  padding: 0.75rem 1.25rem;
  background-color: #5566dd;
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: bold;
  cursor: pointer;
  width: 100%;
  max-width: 480px;
}

/* Tombol Toggle Config Drawer */
.config-toggle {
  display: none;
  padding: 0.5rem 1rem;
  background-color: var(--accent);
  color: white;
  border: none;
  border-radius: 6px;
  font-weight: bold;
  cursor: pointer;
  margin-bottom: 1.5rem;
}

.config-toggle:hover {
  background-color: var(--hover-accent);
}

/* Panel Output */
.output-panel {
  flex: 2 1 600px;
  background: var(--panel-bg);
  padding: 1.5rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  overflow-x: auto;
  transition: background-color 0.3s ease;
}

.output-panel h3 {
  margin: 0 0 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--border);
  color: var(--accent);
  font-size: 1.25rem;
  font-weight: 600;
  max-height: 85vh; /* batasi tinggi relatif ke viewport */
  transition: background-color 0.3s ease;
}

/* Tabel Output */
.output-panel table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  margin-bottom: 1.5rem;
  word-wrap: break-word;
  background-color: var(--panel-bg);
  color: var(--text);
}

.output-panel th,
.output-panel td {
  border: 1px solid var(--border);
  padding: 0.5rem;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.output-panel th {
  background-color: var(--header-bg);
  font-weight: 600;
  color: var(--text);
}

/* Input Pencarian Riwayat */
#history-search {
  width: 100%;
  padding: 0.5rem;
  margin: 1rem 0;
  border-radius: 6px;
  border: 1px solid var(--border);
  background-color: var(--panel-bg);
  color: var(--text);
  transition: all 0.2s ease;
}

/* Scrollable Box untuk Riwayat */
.scrollable-box {
  height: 300px;
  overflow-y: auto;
  padding-right: 0.5rem;
  scrollbar-width: thin;
}

/* Item Accordion */
.accordion-item {
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 1rem;
  background-color: var(--panel-bg);
  transition: background-color 0.3s ease;
}

/* Header Accordion */
.accordion-header {
  padding: 0.75rem 1rem;
  background-color: var(--header-bg);
  color: var(--text);
  font-weight: 600;
  border-radius: 8px 8px 0 0;
  cursor: pointer;
  transition: background-color 0.3s ease;
}

/* Body Accordion */
.accordion-body {
  padding: 1rem;
  border-top: 1px solid var(--border);
  background-color: var(--panel-bg);
  transition: all 0.3s ease;
}

.accordion-body.hidden {
  display: none;
}

/* Fade-out saat menghapus item */
.fade-out {
  opacity: 0;
  transition: opacity 0.5s ease-out;
}

/* Tombol Ekspor */
#export-buttons {
  display: flex;
  gap: 1rem;
  margin-top: 1.5rem;
  flex-wrap: wrap;
}

#export-buttons button {
  flex: 1 1 auto;
  min-width: 120px;
}

/* Footer */
footer {
  text-align: center;
  margin-top: 3rem;
  padding: 1rem;
  font-size: 0.875rem;
  color: #666;
}

/* Desktop/Mobile Tombol */
.desktop-only {
  width: 100%;
}

/* Kartu Output (Mobile) */
.mobile-only .mobile-card {
  background-color: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 1rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  transition: background-color 0.3s ease;
}

.mobile-card p small {
  display: block;
  margin-top: 0.25rem;
  color: #666;
  font-size: 0.875rem;
}

/* Dua Kolom di Mobile (Grid-style) */
.card-line {
  display: grid;
  grid-template-columns: 100px 1fr;
  gap: 0.5rem;
  align-items: start;
  margin-bottom: 0.75rem;
}

.card-line strong {
  font-weight: 600;
  color: var(--text);
}

/* DoB dua baris (mobile khusus) */
.mobile-card .dob-wrapper {
  display: flex;
  flex-direction: column;
  margin-bottom: 0.5rem;
}

.mobile-card .dob-wrapper p {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
}

.mobile-card .dob-wrapper .dob-split-indent {
  padding-left: 100px; /* sejajar dengan label DoB */
  font-size: 0.95em;
  color: var(--text);
}

/* Responsif Mobile */
@media (max-width: 1023.9px) {
  .layout {
    flex-direction: column;
  }

  .output-panel,
  .config-panel {
    width: 100%;
  }

  .generate-mobile-btn {
    display: block;
    width: auto;
  }

  #generator-form button[type="submit"] {
    display: none;
  }

  .desktop-only {
    display: none;
  }

  .mobile-only {
    display: block;
    margin-bottom: 1rem;
  }
  .dob-wrapper {
    display: flex;
    flex-direction: column;
  }

  .dob-line {
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.5em;
  }

  .dob-split-indent {
    padding-left: 5.4em; /* Sesuaikan agar rata dengan tanggal, bukan label "DoB:" */
    font-size: 0.95em;
  }

  .mobile-card .dob-wrapper {
    display: flex;
    flex-direction: column;
    margin-bottom: 0.5rem;
  }

  .mobile-card .dob-wrapper p {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
  }

  .mobile-card .dob-wrapper .dob-split-indent {
    padding-left: 120px; /* Sesuaikan agar rata dengan label "DoB:" */
    font-size: 0.95em;
  }

  .config-toggle {
    display: block;
  }

  .config-panel {
    position: fixed;
    top: 0;
    left: -100%;
    width: 85%;
    max-width: 360px;
    height: 100%;
    background-color: #ffffff;
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.2);
    z-index: 1000;
    padding: 1.5rem;
    transition: left 0.3s ease-in-out;
    overflow-y: auto;
  }

  .config-panel.open {
    left: 0;
  }

  .overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 900;
  }

  .overlay.show {
    display: block;
  }

  .info-row,
  .card-line {
    grid-template-columns: 100px 1fr;
  }
}
/* Tombol mobile: hanya muncul di bawah 1023.9px */
.top-actions {
  display: none;
}

@media (max-width: 1023.9px) {
  .top-actions.mobile-only {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 0.75rem;
    padding: 0 1rem;
    margin-top: 1rem;
  }

  /* Tombol konfigurasi icon (gear) */
  .top-actions .config-toggle {
    background-color: #446688;
    color: #fff;
    border: none;
    border-radius: 6px;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    font-size: 1.2rem;
    cursor: pointer;
  }

  .top-actions .config-toggle:hover {
    background-color: #2f4c6d;
  }

  /* Tombol generate di mobile */
  .top-actions .generate-mobile-btn {
    margin: 0;
    padding: 0.6rem 1rem;
    background-color: #5566dd;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 0.95rem;
    font-weight: bold;
    cursor: pointer;
  }

  /* Sembunyikan tombol submit desktop & config drawer */
  #generator-form button[type="submit"] {
    display: none;
  }

  #toggle-config:not(.top-actions .config-toggle) {
    display: none;
  }
}
/* Hapus margin bawah bawaan tombol config jika ada */
.top-actions .config-toggle {
  margin-bottom: 0 !important;
}

/* Modal Form */
.modal {
  position: fixed;
  inset: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.modal.hidden {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  backdrop-filter: blur(8px);
  background: rgba(0, 0, 0, 0.4);
  z-index: -1;
}

.modal-content {
  background: var(--panel-bg);
  padding: 1.5rem;
  border-radius: 12px;
  width: 90%;
  max-width: 400px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  z-index: 1;
}

.modal-content h3 {
  margin-top: 0;
  font-size: 1.2rem;
  color: var(--text);
}

.modal-content input,
.modal-content textarea {
  width: 100%;
  margin-bottom: 1rem;
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background-color: var(--panel-bg);
  color: var(--text);
}

.modal-content textarea {
  min-height: 80px;
}

/* Tombol Form Modal */
.form-actions {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
}

.form-actions button {
  flex: 1;
  padding: 0.5rem;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-weight: bold;
  color: white;
}

.form-actions button:first-child {
  background-color: #4caf50;
}
.form-actions button:last-child {
  background-color: #f44336;
}

/* Konfirmasi Hapus */
.confirm-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(2px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 2000;
}

.confirm-modal.hidden {
  display: none;
}

.confirm-box {
  background: var(--panel-bg);
  padding: 1em 1.5em;
  border-radius: 8px;
  max-width: 300px;
  box-shadow: 0 5px 20px rgba(0, 0, 0, 0.2);
  text-align: center;
  color: var(--text);
}

.confirm-actions {
  margin-top: 1em;
  display: flex;
  justify-content: space-between;
}

.confirm-actions button {
  padding: 0.5em 1em;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  font-weight: bold;
  color: white;
}

#confirm-no,
.confirm-actions button:last-child {
  background-color: #e25a5a;
}
#confirm-no:hover {
  background-color: #c44141;
}

.delete-entry {
  background-color: #f44336;
  color: white;
  margin-bottom: 1rem;
}

/* Tambahan dark mode yang nyaman di mata */
:root {
  --bg: #f5f7fa;
  --text: #333;
  --panel-bg: #fff;
  --border: #e2e6ea;
  --accent: #446688;
  --hover-accent: #335577;
  --header-bg: #f3f4f6;
  --heading: #222;
  --label: #444;
}

html.dark-mode {
  --bg: #181a1f;
  --text: #f0f2f5;
  --panel-bg: #23252b;
  --border: #3c3f45;
  --accent: #80aaff;
  --hover-accent: #5c84c4;
  --header-bg: #2e3138;
  --heading: #ffffff;
  --label: #dddddd;
}

body {
  background-color: var(--bg);
  color: var(--text);
  transition: background-color 0.3s ease, color 0.3s ease;
}

.config-panel,
.output-panel,
.accordion-body,
.accordion-header,
.mobile-card,
.modal-content,
.confirm-box {
  background-color: var(--panel-bg);
  color: var(--text);
  border-color: var(--border);
  transition: background-color 0.3s ease, color 0.3s ease;
}

.accordion-header {
  background-color: var(--header-bg);
}

/* Header tabel */
.output-panel th {
  background-color: var(--header-bg);
  color: var(--text);
}

/* Label dan teks penting */
strong,
.card-line strong,
.info-row .label,
.accordion-header,
.modal-content h3 {
  color: var(--text) !important;
}

/* Input dan select */
input,
select,
textarea {
  background-color: var(--panel-bg);
  color: var(--text);
  border-color: var(--border);
}

/* Tombol */
button {
  color: white;
  transition: background-color 0.3s ease;
}

button:hover {
  background-color: var(--hover-accent);
}

.copyable:hover {
  color: #fff;
}

/* Tombol konfirmasi khusus */
#confirm-no,
.form-actions button:last-child {
  background-color: #e25a5a;
}

#confirm-no:hover,
.form-actions button:last-child:hover {
  background-color: #c44141;
}

/* Transisi Umum */
.config-panel,
.output-panel,
.accordion-header,
.accordion-body,
.modal-content,
.confirm-box {
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* Fade saat Hapus */
.fade-out {
  opacity: 0;
  transition: opacity 0.5s ease-out;
}

/* Copyable Hover */
.copyable {
  cursor: pointer;
  color: var(--text);
}
.copyable:hover {
  color: #fff;
}

/* Tambahan List Flat */
.recent-flat-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 16px;
}
.flat-row {
  padding: 8px;
  background: var(--panel-bg);
  border-radius: 4px;
}

.flat-item {
  margin: 4px 0;
}

/* Heading besar */
h1,
h2,
h3,
h4,
h5,
h6 {
  color: var(--heading);
}

/* Label form */
label,
.config-panel label,
.accordion-header,
.info-row .label,
.card-line strong {
  color: var(--label);
}
html.dark-mode input,
html.dark-mode select,
html.dark-mode textarea {
  background-color: var(--panel-bg);
  color: var(--text);
  border-color: var(--border);
  caret-color: var(--text);
}

/* Untuk placeholder teks (jika kamu pakai) */
html.dark-mode input::placeholder,
html.dark-mode textarea::placeholder {
  color: #aaa;
}

/* Fokus: saat input disorot */
html.dark-mode input:focus,
html.dark-mode select:focus,
html.dark-mode textarea:focus {
  outline: 2px solid var(--accent);
  background-color: var(--panel-bg);
  color: var(--text);
}

/* HR */
hr {
  border: none;
  border-top: 1px solid #aaa3;
  margin: 8px 0;
}
/* Tombol copy flat style responsif */
.flat-item {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.flat-item button.copyable {
  flex: 1 1 auto;
  padding: 0.4rem 0.75rem;
  background-color: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.3s ease;
  white-space: nowrap;
}

.flat-item button.copyable:hover {
  background-color: var(--hover-accent);
}

.flat-item button.edit-extra {
  padding: 0.4rem 0.75rem;
  background-color: #8884d8;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.3s ease;
}

.flat-item button.edit-extra:hover {
  background-color: #6b65b9;
}

@media (max-width: 480px) {
  .flat-item button.copyable,
  .flat-item button.edit-extra {
    flex: 1 1 30%;
    font-size: 0.85rem;
    padding: 0.4rem 0.5rem;
  }
}
.scrollable-box {
  height: 350px;
  overflow-y: auto;
  padding-right: 0.5rem;

  /* Firefox support */
  scrollbar-width: thin;
  scrollbar-color: var(--accent) transparent;
}

/* Chrome/Safari */
.scrollable-box::-webkit-scrollbar {
  width: 6px;
}

.scrollable-box::-webkit-scrollbar-track {
  background: transparent;
}

.scrollable-box::-webkit-scrollbar-thumb {
  background-color: var(--accent);
  border-radius: 4px;
}

.scrollable-box::-webkit-scrollbar-thumb:hover {
  background-color: var(--hover-accent);
}

/* Fullname */
.flat-item:first-of-type button.copyable:nth-child(1) {
  background-color: #4a90e2; /* Biru */
}
.flat-item:first-of-type button.copyable:nth-child(1):hover {
  background-color: #357ab8;
}

/* Username */
.flat-item:first-of-type button.copyable:nth-child(2) {
  background-color: #00b894; /* Hijau emerald */
}
.flat-item:first-of-type button.copyable:nth-child(2):hover {
  background-color: #009e7a;
}

/* Tanggal: DD, MM, YYYY */
.flat-item:nth-of-type(2) button.copyable:nth-child(1) {
  background-color: #ffa94d; /* DD - oranye */
}
.flat-item:nth-of-type(2) button.copyable:nth-child(2) {
  background-color: #ffd43b; /* MM - kuning */
}
.flat-item:nth-of-type(2) button.copyable:nth-child(3) {
  background-color: #94d82d; /* YYYY - hijau muda */
}
.flat-item:nth-of-type(2) button.copyable:hover {
  filter: brightness(0.9);
}

/* Password */
.flat-item:nth-of-type(3) button.copyable {
  background-color: #e85959;
}
.flat-item:nth-of-type(3) button.copyable:hover {
  background-color: #c0392b;
}

/* Tambah Info */
.flat-item:nth-of-type(4) button.edit-extra {
  background-color: #6c5ce7;
}
.flat-item:nth-of-type(4) button.edit-extra:hover {
  background-color: #4834d4;
}
