/* DIGI Saha sender page. Mobile first, no external assets, light/dark aware. */
:root {
  --bg: #f2f4f7;
  --card: #ffffff;
  --text: #15202b;
  --muted: #5b6b7b;
  --border: #d5dbe3;
  --field: #ffffff;
  --accent: #0f5fb0;
  --accent-text: #ffffff;
  --accent-soft: #e3effb;
  --danger: #c62828;
  --danger-soft: #fdecea;
  --ok: #1b7f3b;
  --ok-soft: #e6f4ea;
  --warn: #9a6200;
  --warn-soft: #fff4dc;
  --flash: #d32f2f;
  --bar-bg: #e3e8ee;
  --radius: 14px;
  --tap: 52px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1117;
    --card: #161b22;
    --text: #e6edf3;
    --muted: #9aa7b4;
    --border: #2f3a46;
    --field: #0d1117;
    --accent: #4aa3ff;
    --accent-text: #04121f;
    --accent-soft: #10263d;
    --danger: #ff6b6b;
    --danger-soft: #3a1717;
    --ok: #5fd38a;
    --ok-soft: #12301d;
    --warn: #f0b44c;
    --warn-soft: #33270f;
    --flash: #ff5a5a;
    --bar-bg: #2a333d;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}

.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: #0f3d6e; color: #fff;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 19px; letter-spacing: .2px; }
.brand img { border-radius: 7px; }
.who { display: flex; align-items: center; gap: 10px; min-width: 0; }
.who-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 46vw; opacity: .95; }
.link-btn {
  background: transparent; border: 1px solid rgba(255,255,255,.55); color: #fff;
  border-radius: 999px; padding: 6px 14px; font: inherit; font-size: 15px; min-height: 40px; cursor: pointer;
}

main { max-width: 680px; margin: 0 auto; padding: 14px 12px 40px; }

.card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 16px; margin-bottom: 14px;
}
h1 { font-size: 22px; margin: 0 0 12px; }
h2 { font-size: 19px; margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 14px; }

label { display: block; font-weight: 600; margin: 14px 0 6px; }
input[type=text], input[type=password], textarea, select {
  width: 100%; font: inherit; font-size: 17px; /* >=16px: no iOS zoom on focus */
  color: var(--text); background: var(--field);
  border: 1px solid var(--border); border-radius: 10px; padding: 12px; min-height: var(--tap);
}
textarea { resize: vertical; min-height: 140px; }
select { appearance: none; -webkit-appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 20px) 50%, calc(100% - 14px) 50%; background-size: 6px 6px; background-repeat: no-repeat; padding-right: 36px; }
input:focus, textarea:focus, select:focus, .btn:focus-visible { outline: 3px solid var(--accent); outline-offset: 1px; }

label.check { display: flex; align-items: center; gap: 10px; font-weight: 400; min-height: 44px; margin: 6px 0; }
label.check input { width: 22px; height: 22px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap); padding: 10px 18px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--accent-soft); color: var(--text);
  font: inherit; font-weight: 600; cursor: pointer; text-align: center; user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); width: 100%; margin-top: 16px; }
.btn.big { min-height: 60px; font-size: 19px; }
.btn[disabled] { opacity: .55; cursor: default; }
.small-btn { min-height: 44px; padding: 6px 14px; font-size: 15px; }

.switch-row { margin-top: 14px; }
label.switch { display: flex; align-items: center; gap: 14px; margin: 0; min-height: var(--tap); cursor: pointer; font-weight: 400; }
label.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.slider { position: relative; flex: 0 0 auto; width: 56px; height: 32px; border-radius: 999px; background: var(--bar-bg); border: 1px solid var(--border); transition: background .15s; }
.slider::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.35); transition: transform .15s; }
label.switch input:checked + .slider { background: var(--accent); border-color: var(--accent); }
label.switch input:checked + .slider::after { transform: translateX(24px); }
label.switch input#flash:checked + .slider { background: var(--flash); border-color: var(--flash); }
label.switch input:focus-visible + .slider { outline: 3px solid var(--accent); outline-offset: 2px; }
.switch-text { display: flex; flex-direction: column; }
.switch-text small { color: var(--muted); font-size: 14px; }

fieldset.files { border: 0; padding: 0; margin: 18px 0 0; }
fieldset.files legend { font-weight: 600; padding: 0; margin-bottom: 8px; }
.pickers { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.pick { position: relative; margin: 0; padding: 10px 6px; font-size: 15px; min-height: 64px; }
.pick.wide { grid-column: 1 / -1; }
.vh { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; clip: rect(0 0 0 0); }

.file-list, .upload-list, .mine-list { list-style: none; margin: 10px 0 0; padding: 0; }
.file-list li, .upload-list li, .mine-list li {
  border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; margin-top: 8px;
}
.file-list li { display: flex; align-items: center; gap: 10px; }
.file-list .fname, .upload-list .fname { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-list .fsize { color: var(--muted); font-size: 14px; white-space: nowrap; }
.remove-btn { min-height: 44px; min-width: 44px; padding: 4px 10px; font-size: 14px; background: transparent; }

.bar { height: 10px; border-radius: 999px; background: var(--bar-bg); overflow: hidden; margin-top: 8px; }
.bar.total { height: 14px; margin-top: 12px; }
.bar .fill { height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.upload-list li.done .fill { background: var(--ok); }
.upload-list li.failed .fill { background: var(--danger); }
.upload-list .line { display: flex; gap: 10px; align-items: baseline; }
.upload-list .fstate { font-size: 14px; color: var(--muted); white-space: nowrap; }
.upload-list li.done .fstate { color: var(--ok); }
.upload-list li.failed .fstate { color: var(--danger); }

.banner { border-radius: 10px; padding: 12px; margin: 12px 0 0; background: var(--accent-soft); }
.banner.error { background: var(--danger-soft); color: var(--danger); }
.banner.ok { background: var(--ok-soft); color: var(--ok); font-weight: 600; }
.banner.warn { background: var(--warn-soft); color: var(--warn); }

.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row .btn { flex: 1; }
.row.space { justify-content: space-between; align-items: center; }
.row.space .btn { flex: 0 0 auto; }

.mine-list .mtitle { font-weight: 600; overflow-wrap: anywhere; }
.mine-list .mmeta { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; margin-top: 4px; font-size: 14px; color: var(--muted); }
.badge { display: inline-block; border-radius: 999px; padding: 2px 10px; font-size: 13px; font-weight: 700; background: var(--bar-bg); color: var(--text); }
.badge.uploading { background: var(--warn-soft); color: var(--warn); }
.badge.ready { background: var(--accent-soft); color: var(--accent); }
.badge.delivered, .badge.used { background: var(--ok-soft); color: var(--ok); }
.badge.flash { background: var(--flash); color: #fff; }

@media (min-width: 560px) {
  .pickers { grid-template-columns: repeat(4, 1fr); }
  .pick.wide { grid-column: auto; }
}
