/* ==========================================================================
   SuperFile - panel provider
   Satu warna aksen (teal) dipakai di tombol utama, focus ring, dan titik status.
   Sisanya skala netral supaya tabel mudah dibaca lama-lama.
   ========================================================================== */

:root {
  --font: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --mono: "Cascadia Mono", Consolas, "SF Mono", ui-monospace, monospace;

  --bg: #f5f5f4;
  --surface: #ffffff;
  --surface-2: #fafaf9;
  --fg: #1c1917;
  --muted: #57534e;
  --line: #e7e5e4;
  --line-strong: #d6d3d1;

  --accent: #0f766e;
  --accent-hover: #115e59;
  --accent-fg: #ffffff;
  --accent-soft: #ccfbf1;

  --ok: #15803d;
  --ok-soft: #dcfce7;
  --danger: #b91c1c;
  --danger-soft: #fee2e2;
  --warn: #92400e;
  --warn-soft: #fef3c7;

  --radius: 8px;
  --radius-sm: 6px;
}

[data-theme="dark"] {
  --bg: #0c0a09;
  --surface: #1c1917;
  --surface-2: #292524;
  --fg: #f5f5f4;
  --muted: #a8a29e;
  --line: #32302d;
  --line-strong: #44403c;

  --accent: #2dd4bf;
  --accent-hover: #5eead4;
  --accent-fg: #0c0a09;
  --accent-soft: #134e4a;

  --ok: #86efac;
  --ok-soft: #0b2f1a;
  --danger: #fca5a5;
  --danger-soft: #3b0d0d;
  --warn: #fcd34d;
  --warn-soft: #3a2506;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 400 15px/1.55 var(--font);
}

h1,
h2 {
  margin: 0;
  font-weight: 650;
  letter-spacing: -0.01em;
}

h1 {
  font-size: 1.0625rem;
}

h2 {
  font-size: 1rem;
}

p {
  margin: 0;
}

a {
  color: var(--accent);
}

a:hover {
  text-decoration-thickness: 2px;
}

code {
  font-family: var(--mono);
  font-size: 0.85em;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0.05rem 0.3rem;
}

.mono {
  font-family: var(--mono);
  font-size: 0.8125rem;
}

.muted {
  color: var(--muted);
  font-size: 0.875rem;
}

/* --------------------------------------------------------------------------
   Kerangka halaman
   -------------------------------------------------------------------------- */

.shell {
  max-width: 1040px;
  margin: 0 auto;
  padding: 0 1.25rem 2.5rem;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 1.35rem 0 1.1rem;
  border-bottom: 1px solid var(--line);
  margin-bottom: 1.5rem;
}

.brand-sub {
  color: var(--muted);
  font-size: 0.8125rem;
}

.topbar-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

main {
  display: block;
}

.site-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.5rem;
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.8125rem;
}

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

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.15rem 1.25rem 1.35rem;
  margin-bottom: 1.25rem;
}

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.card-head .muted {
  margin-top: 0.15rem;
}

/* --------------------------------------------------------------------------
   Tombol
   -------------------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  min-height: 2.25rem;
  padding: 0.4rem 0.85rem;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.2;
  color: var(--fg);
  background: transparent;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-decoration: none;
  transition: background-color 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

.btn:hover {
  background: var(--surface-2);
}

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

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-fg);
}

.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn-quiet {
  background: transparent;
}

.btn-danger {
  color: var(--danger);
  border-color: var(--line-strong);
}

.btn-danger:hover {
  background: var(--danger-soft);
  border-color: var(--danger);
}

.btn-small {
  min-height: 2rem;
  padding: 0.3rem 0.6rem;
  font-size: 0.8125rem;
}

.btn-block {
  width: 100%;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* --------------------------------------------------------------------------
   Form
   -------------------------------------------------------------------------- */

.stack {
  display: grid;
  gap: 0.85rem;
}

.grid-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.9rem 1.1rem;
  margin-top: 0.9rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  min-width: 0;
}

.field-wide {
  grid-column: 1 / -1;
}

.field label {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--muted);
}

input[type="text"],
input[type="password"],
input[type="number"],
select {
  width: 100%;
  min-height: 2.4rem;
  padding: 0.45rem 0.6rem;
  font: inherit;
  font-size: 0.9375rem;
  color: var(--fg);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
}

input.mono,
select.mono {
  font-family: var(--mono);
  font-size: 0.8125rem;
}

input::placeholder {
  color: var(--muted);
  opacity: 0.75;
}

.hint {
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.45;
}

.check {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin-top: 0.15rem;
  font-size: 0.8125rem;
  color: var(--muted);
  cursor: pointer;
}

.check input {
  width: 1rem;
  height: 1rem;
  accent-color: var(--accent);
  cursor: pointer;
}

.form-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.2rem;
}

.inline-form {
  display: inline;
}

/* --------------------------------------------------------------------------
   Pesan
   -------------------------------------------------------------------------- */

.alert {
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.75rem;
  margin: 0 0 1rem;
  font-size: 0.875rem;
  list-style-position: inside;
}

.alert-error {
  color: var(--danger);
  background: var(--danger-soft);
  border-color: var(--danger);
}

.alert-ok {
  color: var(--ok);
  background: var(--ok-soft);
  border-color: var(--ok);
}

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

.providers {
  width: 100%;
  border-collapse: collapse;
}

.providers th {
  padding: 0.5rem 0.6rem;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--muted);
  text-align: left;
  border-bottom: 1px solid var(--line-strong);
  white-space: nowrap;
}

.providers td {
  padding: 0.7rem 0.6rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

.providers tbody tr:last-child td {
  border-bottom: 0;
}

.p-name {
  display: block;
  font-weight: 600;
}

.p-meta {
  display: block;
  margin-top: 0.1rem;
  color: var(--muted);
  word-break: break-all;
}

.num {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.1rem 0.45rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge::before {
  content: "";
  width: 0.4rem;
  height: 0.4rem;
  border-radius: 50%;
  background: currentColor;
}

.badge-active {
  color: var(--ok);
  background: var(--ok-soft);
}

.badge-inactive {
  color: var(--muted);
  background: var(--surface-2);
}

.badge-full {
  color: var(--warn);
  background: var(--warn-soft);
}

.badge-error {
  color: var(--danger);
  background: var(--danger-soft);
}

.testmsg {
  display: block;
  margin-top: 0.3rem;
  max-width: 24rem;
  font-size: 0.75rem;
  line-height: 1.45;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.testmsg.is-ok {
  color: var(--ok);
}

.testmsg.is-fail {
  color: var(--danger);
}

.testmsg.is-pending {
  color: var(--muted);
}

.empty-row td {
  padding: 1.75rem 0.6rem;
  text-align: center;
}

.empty-title {
  font-weight: 600;
  margin-bottom: 0.2rem;
}

.empty-row .btn {
  margin-top: 0.75rem;
}

/* --------------------------------------------------------------------------
   Halaman login
   -------------------------------------------------------------------------- */

.login-main {
  display: flex;
  justify-content: center;
  padding: 3rem 0 4rem;
}

.login-card {
  width: 100%;
  max-width: 380px;
}

.login-card h2 {
  margin-bottom: 0.2rem;
}

.login-card .muted {
  margin-bottom: 1rem;
}

.login-card .hint {
  margin-top: 0.9rem;
}

/* --------------------------------------------------------------------------
   Layar kecil: tabel berubah jadi daftar bertumpuk, tanpa scroll horizontal
   -------------------------------------------------------------------------- */

@media (max-width: 720px) {
  .grid-form {
    grid-template-columns: 1fr;
  }

  .providers thead {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
  }

  .providers tbody tr {
    display: block;
    padding: 0.9rem 0;
    border-bottom: 1px solid var(--line);
  }

  .providers tbody tr:first-child {
    padding-top: 0.2rem;
  }

  .providers tbody tr:last-child {
    border-bottom: 0;
  }

  .providers td {
    display: flex;
    gap: 0.75rem;
    padding: 0.25rem 0;
    border: 0;
  }

  .providers td::before {
    content: attr(data-label);
    flex: 0 0 5.5rem;
    padding-top: 0.1rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--muted);
  }

  .providers td.row-actions,
  .providers td[data-label="Aksi"] {
    flex-wrap: wrap;
  }

  .providers .row-actions {
    flex: 1 1 auto;
  }

  .btn,
  .btn-small {
    min-height: 2.75rem;
  }

  .empty-row td {
    display: block;
    text-align: left;
  }

  .empty-row td::before {
    content: none;
  }

  .topbar {
    align-items: flex-start;
  }
}

/* --------------------------------------------------------------------------
   Halaman upload publik
   -------------------------------------------------------------------------- */

.upload-layout {
  display: grid;
  gap: 1.25rem;
}

.upload-form {
  display: grid;
  gap: 1rem;
  margin-top: 1rem;
}

/* Tetap bisa menerima fokus keyboard walau tidak terlihat. */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  padding: 1.8rem 1rem;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface-2);
  text-align: center;
  cursor: pointer;
}

.dropzone:hover,
.dropzone.is-dragover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.dropzone:focus-within {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.dropzone-title {
  font-weight: 600;
}

.dropzone-hint {
  color: var(--muted);
  font-size: 0.8125rem;
  overflow-wrap: anywhere;
}

.dropzone.is-busy {
  opacity: 0.6;
  cursor: progress;
}

/* Fase 7: daftar file terpilih + status per file */

.file-list {
  display: grid;
  gap: 0.3rem;
  max-height: 13rem;
  overflow-y: auto;
  margin: 0;
  padding: 0;
  list-style: none;
}

.file-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: 0.875rem;
}

.file-row-name {
  min-width: 0;
  overflow-wrap: anywhere;
}

.file-row-size {
  flex: none;
  color: var(--muted);
  font-size: 0.8125rem;
  font-variant-numeric: tabular-nums;
}

.file-row.is-current {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.file-row.is-done {
  border-color: var(--ok);
  background: var(--ok-soft);
  color: var(--ok);
}

.file-row.is-fail {
  border-color: var(--danger);
  background: var(--danger-soft);
  color: var(--danger);
}

.file-row.is-cancelled {
  border-style: dashed;
  color: var(--muted);
}

.progress-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  font-size: 0.8125rem;
}

.progress-title {
  font-weight: 600;
  overflow-wrap: anywhere;
}

.progress-percent {
  flex: none;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

#progress-overall {
  height: 0.5rem;
}

.progress-wrap {
  display: grid;
  gap: 0.35rem;
}

progress {
  width: 100%;
  height: 0.65rem;
  appearance: none;
  border: 0;
  border-radius: 999px;
  background: var(--line);
}

progress::-webkit-progress-bar {
  background: var(--line);
  border-radius: 999px;
}

progress::-webkit-progress-value {
  background: var(--accent);
  border-radius: 999px;
}

progress::-moz-progress-bar {
  background: var(--accent);
  border-radius: 999px;
}

.result-box {
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 0.85rem 1rem;
  margin-top: 1rem;
}

.result-box.is-fail {
  color: var(--danger);
  background: var(--danger-soft);
  border-color: var(--danger);
}

.result-box.is-warn {
  color: var(--warn);
  background: var(--warn-soft);
  border-color: var(--warn);
}

.result-box a {
  color: inherit;
  text-decoration: underline;
  overflow-wrap: anywhere;
}

.result-title {
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.result-details {
  margin: 0.6rem 0 0;
  padding-left: 1.2rem;
  font-size: 0.8125rem;
}

.provider-list {
  display: grid;
  gap: 0.4rem;
  margin: 0.75rem 0 0;
  padding-left: 1.25rem;
}

.provider-list li {
  display: flex;
  gap: 0.75rem;
  justify-content: space-between;
  flex-wrap: wrap;
}

/* --------------------------------------------------------------------------
   Gate password situs & riwayat upload (fase 3)
   -------------------------------------------------------------------------- */

.gate-main {
  display: flex;
  justify-content: center;
  padding: 2.5rem 0 4rem;
}

.gate-card {
  width: 100%;
  max-width: 380px;
}

.gate-card .stack {
  margin-top: 1rem;
}

/* Tombol gate dan tombol salin tetap 44px walau layar lebar. */
.gate-card .btn,
.history .btn-small {
  min-height: 2.75rem;
}

.history-link {
  display: block;
  max-width: 28rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-time {
  white-space: nowrap;
  color: var(--muted);
  font-size: 0.875rem;
}

/* Baris hasil upload terbaru setelah redirect ?baru=1. */
.history tr.is-new td {
  background: var(--ok-soft);
}

/* Ukuran file tetap satu baris. */
.history-size {
  white-space: nowrap;
}

/* Link Telegraph + tombol salin dalam satu sel.
   Anchor boleh menyusut dan memakai elipsis supaya kolom Waktu tidak terdorong. */
.link-cell {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}

.link-cell .history-link {
  flex: 1 1 8rem;
  min-width: 0;
  max-width: 100%;
}

.link-cell .btn-small {
  flex: 0 0 auto;
}

/* Nama file + tombol salin nama (tap to copy).
   Satu baris: nama boleh wrap di kotaknya sendiri, tombol tetap di kanan. */
.name-cell {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}

.name-cell .p-name {
  flex: 1 1 auto;
  min-width: 0;
  overflow-wrap: anywhere;
}

.name-cell .btn-small {
  flex: 0 0 auto;
}

/* Tombol salin nama ringkas: teks pendek, tinggi sentuh tetap 44px. */
.name-copy {
  padding-inline: 0.55rem;
  min-height: 2.75rem;
}

@media (min-width: 641px) {
  /* Layout tetap: kolom Ukuran dan Waktu punya lebar pasti, sisanya dibagi
     nama file + link. Tanpa ini URL panjang mendorong kolom Waktu keluar kartu. */
  .history {
    table-layout: fixed;
    width: 100%;
  }

  .history th:nth-child(1),
  .history td:nth-child(1) {
    width: 30%;
  }

  .history th:nth-child(2),
  .history td:nth-child(2) {
    width: 6.5rem;
  }

  .history th:nth-child(4),
  .history td:nth-child(4) {
    width: 9.5rem;
  }

  .history td {
    overflow: hidden;
  }
}

@media (min-width: 900px) {
  /* Di layar lebar tombol salin duduk sebaris di kanan link yang terpotong. */
  .link-cell {
    flex-wrap: nowrap;
  }
}

@media (max-width: 640px) {
  .history-link {
    max-width: 100%;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .history-time {
    white-space: normal;
  }
}

/* --------------------------------------------------------------------------
   Riwayat dua tingkat (fase 5): daftar tanggal, tombol kembali, navigasi
   -------------------------------------------------------------------------- */

.card-head-action {
  flex: 0 0 auto;
}

/* Daftar tanggal: satu baris penuh yang bisa diklik, bukan tabel,
   supaya di 390px tidak butuh scroll horizontal. */
.date-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--line);
}

.date-list li + li {
  border-top: 1px solid var(--line);
}

.date-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-height: 2.75rem;
  padding: 0.75rem 0.4rem;
  border-radius: var(--radius-sm);
  color: inherit;
  text-decoration: none;
}

.date-row:hover {
  background: var(--surface-2);
  text-decoration: none;
}

.date-row:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.date-value {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.date-count {
  margin-left: auto;
  color: var(--muted);
  font-size: 0.8125rem;
  white-space: nowrap;
}

.date-chev {
  color: var(--accent);
  font-size: 0.9375rem;
}

/* Tanggal teratas setelah redirect ?baru=1. */
.date-row.is-new {
  background: var(--ok-soft);
}

/* Navigasi halaman sederhana: info halaman di kiri, tombol di kanan. */
.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-top: 1.1rem;
  padding-top: 0.9rem;
  border-top: 1px solid var(--line);
}

.pager-info {
  color: var(--muted);
  font-size: 0.8125rem;
  font-variant-numeric: tabular-nums;
}

.pager-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* Empty state di luar tabel (daftar tanggal kosong). */
.empty-state {
  padding: 1.75rem 0.5rem;
  text-align: center;
}

.empty-state .btn {
  margin-top: 0.9rem;
}

@media (max-width: 420px) {
  /* Di layar sempit tombol navigasi melebar penuh agar mudah disentuh. */
  .pager-actions {
    width: 100%;
  }

  .pager-actions .btn {
    flex: 1 1 auto;
    justify-content: center;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
    animation: none !important;
  }

  .btn:active {
    transform: none;
  }
}
