/*
 * style.css — Trezor Prístupov
 *
 * Design tokens and component classes are ported from the validated
 * click-through prototype (trezor-prototyp.html) so the real app looks
 * identical. What's NOT ported is the prototype's "phone mockup" chrome
 * (fake status bar, dynamic island, hardware bezel) — this file styles a
 * real full-viewport PWA instead of a phone illustration inside a webpage.
 */

@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500&display=swap');

:root{
  --bg: #f5f6f4;
  --surface: #ffffff;
  --surface-2: #eceeec;
  --text: #171b17;
  --text-muted: #565f5b;
  --border: #d9ddd8;
  --accent: #0d6b6f;
  --accent-soft: #e2f0ef;
  --accent-ink: #ffffff;
  --warn: #8a5a00;
  --warn-soft: #fbf0dc;
  --danger: #9a3324;
  --danger-soft: #fbe9e5;
  --mono-bg: #eef1ee;
  --shadow: 0 1px 2px rgba(20,25,20,0.04), 0 8px 24px -12px rgba(20,25,20,0.12);
}
@media (prefers-color-scheme: dark){
  :root:not([data-theme="light"]){
    --bg: #10130f; --surface: #171b16; --surface-2: #1e231d;
    --text: #e7ebe5; --text-muted: #99a397; --border: #2c332a;
    --accent: #5fc9c4; --accent-soft: #1b2f2c; --accent-ink: #08211f;
    --warn: #e3b34a; --warn-soft: #2e2612; --danger: #e2887a; --danger-soft: #301b16;
    --mono-bg: #1c211b;
    --shadow: 0 1px 2px rgba(0,0,0,0.3), 0 8px 24px -12px rgba(0,0,0,0.5);
  }
}
:root[data-theme="dark"]{
  --bg: #10130f; --surface: #171b16; --surface-2: #1e231d;
  --text: #e7ebe5; --text-muted: #99a397; --border: #2c332a;
  --accent: #5fc9c4; --accent-soft: #1b2f2c; --accent-ink: #08211f;
  --warn: #e3b34a; --warn-soft: #2e2612; --danger: #e2887a; --danger-soft: #301b16;
  --mono-bg: #1c211b;
  --shadow: 0 1px 2px rgba(0,0,0,0.3), 0 8px 24px -12px rgba(0,0,0,0.5);
}

*{ box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body{ height:100%; }
body{
  margin:0;
  background: var(--bg);
  color: var(--text);
  font-family: "IBM Plex Sans", -apple-system, "Segoe UI", sans-serif;
  overscroll-behavior-y: none;
}
.mono{ font-family: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace; }
button{ font-family: inherit; cursor: pointer; color: inherit; }
input, textarea{ font-family: inherit; }
svg{ display:block; flex-shrink:0; }
a{ color: inherit; }

/* ---- app shell (replaces the prototype's phone mockup) ---- */
#app{
  position: fixed; inset:0;
  display:flex; flex-direction:column;
  background: var(--bg);
  overflow:hidden;
}
.app-content{
  flex:1;
  overflow-y:auto;
  -webkit-overflow-scrolling: touch;
  padding: calc(env(safe-area-inset-top, 0px) + 14px) 18px calc(env(safe-area-inset-bottom, 0px) + 24px);
  scrollbar-width: none;
}
.app-content::-webkit-scrollbar{ display:none; }
.screen{ animation: screenIn .16s ease; }
@keyframes screenIn{ from{ opacity:0; transform: translateY(6px);} to{ opacity:1; transform:none;} }

/* ---- shared UI atoms (ported 1:1 from prototype) ---- */
.topbar{ display:flex; align-items:center; gap:10px; padding: 6px 0 14px; }
.icon-btn{
  position:relative;
  background: var(--surface); border:1px solid var(--border); border-radius:10px;
  width:34px; height:34px; display:flex; align-items:center; justify-content:center; color: var(--text);
}
.icon-btn .badge-dot{
  position:absolute; top:-3px; right:-3px; width:9px; height:9px; border-radius:50%;
  background: var(--accent); border:2px solid var(--bg);
}
.icon-btn:hover{ border-color: var(--accent); color: var(--accent); }
.icon-btn.primary{ background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.icon-btn.primary:hover{ color: var(--accent-ink); }
.icon-btn.small{
  width:28px; height:28px; border:none; background:none; color: var(--text-muted); border-radius:8px;
}
.icon-btn.small:hover{ color: var(--accent); background: var(--surface-2); }
.topbar h2{ font-size:17px; margin:0; flex:1; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.topbar .sub{ font-size:11.5px; color: var(--text-muted); display:block; }

.search{
  display:flex; align-items:center; gap:8px;
  background: var(--surface); border:1px solid var(--border); border-radius:10px;
  padding: 9px 12px; margin-bottom:14px; color: var(--text-muted);
}
.search input{
  border:none; outline:none; background:transparent; color:var(--text); font-size:14.5px; width:100%;
}
.search input::placeholder{ color: var(--text-muted); }

.list{ display:flex; flex-direction:column; gap:8px; }
.row-card{
  display:flex; align-items:center; gap:12px;
  background: var(--surface); border:1px solid var(--border); border-radius:12px;
  padding: 12px 12px; text-align:left; width:100%; cursor:pointer;
}
.row-card:hover{ border-color: var(--accent); }
.color-swatch{
  width:32px; height:32px; border-radius:50%; border:2px solid var(--surface);
  box-shadow: 0 0 0 1px var(--border);
}
.color-swatch.active{ box-shadow: 0 0 0 2px var(--accent); }
.field.field-error{ border-color: var(--danger); }

.client-contacts{ display:flex; flex-direction:column; gap:8px; margin:0 0 14px; }
.contact-info-card{
  background: var(--surface); border:1px solid var(--border); border-radius:12px;
  padding:10px 14px; font-size:12.5px; color: var(--text-muted); line-height:1.5;
}
.contact-info-card > div + div{ margin-top:1px; }
.dot{ width:10px; height:10px; border-radius:50%; flex-shrink:0; }
.row-main{ flex:1; min-width:0; }
.row-title{ font-size:14.5px; font-weight:500; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.row-sub{ font-size:12px; color: var(--text-muted); margin-top:1px; }
.badge{
  font-family:"IBM Plex Mono", monospace; font-size:11px; color: var(--text-muted);
  background: var(--surface-2); border-radius: 20px; padding: 2px 9px; flex-shrink:0;
}
.chev{ color: var(--text-muted); flex-shrink:0; }

.type-icon{
  width:36px; height:36px; border-radius:10px; display:flex; align-items:center; justify-content:center;
  background: var(--accent-soft); color: var(--accent); flex-shrink:0;
}
.pill{
  font-family:"IBM Plex Mono", monospace; font-size:10px; letter-spacing:.03em; text-transform:uppercase;
  padding:2px 7px; border-radius:20px; background: var(--surface-2); color: var(--text-muted);
}
.star-btn{ background:none; border:none; color: var(--text-muted); padding:4px; }
.star-btn.active{ color: var(--warn); }
.tags-row{ display:flex; gap:6px; margin-top:6px; flex-wrap:wrap; }
.tag-chip{
  font-family:"IBM Plex Mono", monospace; font-size:10.5px; color: var(--accent);
  background: var(--accent-soft); padding:2px 7px; border-radius:20px;
}

.section-heading{
  font-family:"IBM Plex Mono", monospace; font-size:11px; letter-spacing:.07em; text-transform:uppercase;
  color: var(--text-muted); margin: 18px 0 8px;
}
.section-heading:first-child{ margin-top:0; }

/* vault picker */
.vault-card{
  display:flex; align-items:center; gap:14px; width:100%; text-align:left;
  background: var(--surface); border:1px solid var(--border); border-radius:14px; padding:16px;
}
.vault-card:hover{ border-color: var(--accent); }
.vault-icon{
  width:44px; height:44px; border-radius:12px; display:flex; align-items:center; justify-content:center; color:#fff; flex-shrink:0;
}
.vault-name{ font-size:15.5px; font-weight:600; }
.vault-sub{ font-size:12.5px; color: var(--text-muted); margin-top:2px; }

/* unlock / master password + recovery */
.unlock-wrap{ display:flex; flex-direction:column; align-items:center; padding-top: 8vh; text-align:center; }
.unlock-vault-icon{
  width:60px; height:60px; border-radius:16px; display:flex; align-items:center; justify-content:center; color:#fff; margin-bottom:14px;
}
.unlock-title{ font-size:18px; font-weight:600; margin-bottom:4px; }
.unlock-sub{ font-size:12.5px; color: var(--text-muted); margin-bottom:26px; }
.password-field{
  width:100%; max-width:300px; display:flex; align-items:center; gap:8px;
  background: var(--surface); border:1px solid var(--border); border-radius:12px; padding:12px 14px; margin-bottom:14px;
}
.password-field.error{ border-color: var(--danger); }
.password-field input{
  flex:1; min-width:0; border:none; outline:none; background:transparent; color: var(--text); font-size:15px; letter-spacing:.02em;
}
.password-field button{ background:none; border:none; color: var(--text-muted); padding:4px; }
.password-field button:hover{ color: var(--accent); }
.error-text{ font-size:12px; color: var(--danger); margin: -6px 0 14px; }
.strength-meter{ width:100%; max-width:300px; margin: -6px 0 16px; }
.strength-bar{ height:5px; border-radius:3px; background: var(--surface-2); overflow:hidden; }
.strength-bar > div{ height:100%; border-radius:3px; transition: width .2s ease, background .2s ease; }
.strength-label{ font-size:11px; color: var(--text-muted); margin-top:5px; text-align:right; }
.fp-btn{
  margin-top:8px; display:flex; align-items:center; gap:8px;
  background: var(--accent-soft); color: var(--accent); border:none; border-radius:20px; padding:9px 16px; font-size:13px; font-weight:500;
}
.link-btn{ background:none; border:none; color: var(--accent); font-size:12.5px; padding:8px; margin-top:6px; }
.link-btn:hover{ text-decoration: underline; }

/* buttons */
.btn{
  display:flex; align-items:center; justify-content:center; gap:8px;
  border-radius:12px; padding:13px 18px; font-size:14.5px; font-weight:500;
  border:1px solid var(--border); background: var(--surface); color: var(--text); width:100%;
}
.btn:hover{ border-color: var(--accent); }
.btn-primary{ background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover{ opacity:.92; }
.btn-primary:disabled{ opacity:.5; cursor:default; }
.btn-ghost{ background:none; border:none; }
.btn + .btn{ margin-top:10px; }

/* record detail */
.detail-head{ margin-bottom: 4px; }
.detail-type{ display:flex; align-items:center; gap:10px; margin-bottom:16px; }
.detail-title{ font-size:18px; font-weight:600; }
.detail-meta{ font-size:12px; color: var(--text-muted); margin-top:2px; }

.field{
  background: var(--surface); border:1px solid var(--border); border-radius:12px;
  padding: 12px 14px; margin-bottom:10px;
}
.field-label{ font-size:11.5px; color: var(--text-muted); margin-bottom:4px; }
.field-row{ display:flex; align-items:center; gap:10px; }
.field-value{ flex:1; min-width:0; font-size:15px; letter-spacing:.02em; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.field-actions{ display:flex; gap:6px; }
.field-actions button{
  background: var(--surface-2); border:none; border-radius:8px; width:30px; height:30px;
  display:flex; align-items:center; justify-content:center; color: var(--text-muted);
}
.field-actions button:hover{ color: var(--accent); background: var(--accent-soft); }
.field-actions button.copied{ color: var(--accent); background: var(--accent-soft); }

.note-box{
  background: var(--surface); border:1px solid var(--border); border-radius:12px; padding:14px;
  font-size:13.5px; line-height:1.6; color: var(--text);
}
.note-box ul{ margin:6px 0 0 18px; padding:0; }
.note-box code{ background: var(--mono-bg); padding:1px 5px; border-radius:4px; font-size:.9em; }

.guide-item{
  background: var(--surface); border:1px solid var(--border); border-radius:12px;
  padding:12px 14px; margin-bottom:10px;
}
.guide-item summary{
  cursor:pointer; font-size:13.5px; font-weight:500; color: var(--text); list-style:none;
}
.guide-item summary::-webkit-details-marker{ display:none; }
.guide-item summary::before{ content:'+ '; color: var(--accent); font-family:"IBM Plex Mono", monospace; }
.guide-item[open] summary::before{ content:'– '; }
.guide-item p{ margin:10px 0 0; font-size:13px; line-height:1.55; color: var(--text-muted); }

.toast{
  position:fixed; left:16px; right:16px;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 18px);
  z-index:30; max-width: 420px; margin: 0 auto;
  background: var(--text); color: var(--bg);
  border-radius:12px; padding:11px 14px; display:flex; align-items:center; gap:10px; font-size:13px;
  box-shadow: 0 8px 20px -6px rgba(0,0,0,.4);
  transform: translateY(0); opacity:1; transition: opacity .25s ease, transform .25s ease;
}
.toast.hide{ opacity:0; transform: translateY(8px); pointer-events:none; }
.toast .ring{ position:relative; width:22px; height:22px; flex-shrink:0; }
.toast .ring svg{ transform: rotate(-90deg); }
.toast .ring circle{ fill:none; stroke-width:2.4; }
.toast .ring .track{ stroke: rgba(255,255,255,.25); }
.toast .ring .prog{ stroke: currentColor; stroke-linecap:round; transition: stroke-dashoffset 1s linear; }

.empty{ text-align:center; padding: 40px 10px; color: var(--text-muted); font-size:13px; }

.type-picker{ display:flex; flex-wrap:wrap; gap:8px; margin-bottom:16px; }
.type-chip{
  display:flex; align-items:center; gap:6px; padding:7px 12px; border-radius:20px;
  border:1px solid var(--border); background: var(--surface); color: var(--text-muted); font-size:12.5px;
}
.type-chip svg{ width:14px; height:14px; }
.type-chip.active{ background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.type-chip.add{ border-style: dashed; }

.input-flat{ border:none; outline:none; background:transparent; color:var(--text); font-size:14.5px; width:100%; padding:0; }
.input-flat::placeholder{ color: var(--text-muted); }
textarea.input-flat{ resize:vertical; min-height:72px; line-height:1.55; font-family:inherit; font-size:13.5px; }

.toggle-row{ display:flex; align-items:center; justify-content:space-between; }

.tag-chips{ display:flex; flex-wrap:wrap; gap:6px; margin-bottom:10px; }
.tag-chip-editable{
  display:flex; align-items:center; gap:5px; font-family:"IBM Plex Mono", monospace; font-size:10.5px;
  color: var(--accent); background: var(--accent-soft); padding:3px 6px 3px 9px; border-radius:20px;
}
.tag-chip-editable button{ background:none; border:none; color:inherit; display:flex; padding:1px; }
.tag-add-row{ display:flex; gap:8px; margin-bottom:6px; }
.tag-add-row input{
  flex:1; background: var(--surface); border:1px solid var(--border); border-radius:8px;
  padding:8px 10px; font-size:12.5px; color: var(--text); outline:none;
}
.tag-add-row input:focus{ border-color: var(--accent); }
.tag-add-row button{
  background: var(--surface-2); border:none; border-radius:8px; width:34px; display:flex;
  align-items:center; justify-content:center; color: var(--text-muted);
}
.tag-add-row button:hover{ color: var(--accent); }

.hint{ font-size:11.5px; color: var(--text-muted); margin:-4px 0 16px; }

.danger-link{
  display:flex; align-items:center; gap:7px; color: var(--danger); background:none; border:none;
  font-size:13px; margin-top:10px; padding:8px 2px;
}
.confirm-box{ background: var(--danger-soft); border:1px solid var(--danger); border-radius:12px; padding:13px 14px; margin-top:8px; }
.confirm-box p{ margin:0 0 10px; font-size:13px; color: var(--text); }
.confirm-actions{ display:flex; gap:8px; }
.confirm-actions button{
  flex:1; border-radius:8px; padding:8px; font-size:12.5px; border:1px solid var(--border);
  background: var(--surface); color: var(--text);
}
.confirm-actions button.danger{ background: var(--danger); border-color: var(--danger); color:#fff; }

.icon-picker{ display:flex; flex-wrap:wrap; gap:8px; margin-bottom:16px; }
.icon-choice{
  width:40px; height:40px; border-radius:10px; border:1px solid var(--border); background: var(--surface);
  color: var(--text-muted); display:flex; align-items:center; justify-content:center;
}
.icon-choice.active{ background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

.field-list-row{ display:flex; align-items:center; gap:7px; margin-bottom:8px; }
.field-list-row input[type="text"]{
  flex:1; min-width:0; background: var(--surface); border:1px solid var(--border); border-radius:8px;
  padding:8px 10px; font-size:13px; color: var(--text); outline:none;
}
.field-list-row input[type="text"]:focus{ border-color: var(--accent); }
.sw-btn{
  display:flex; align-items:center; gap:5px; font-size:10.5px; color: var(--text-muted); background: var(--surface-2);
  border:none; border-radius:20px; padding:7px 9px; white-space:nowrap; flex-shrink:0;
}
.sw-btn svg{ width:13px; height:13px; }
.sw-btn.active{ background: var(--accent-soft); color: var(--accent); }
.field-list-row button.remove{ background:none; border:none; color: var(--text-muted); padding:4px; flex-shrink:0; }
.field-list-row button.remove:hover{ color: var(--danger); }

.contact-card{
  position:relative; background: var(--surface-2); border:1px solid var(--border); border-radius:14px;
  padding:14px 40px 4px 14px; margin-bottom:10px;
}
.contact-card .field{ background: var(--surface); padding:10px 14px; }
.field-label.outside{ margin: 0 0 5px 3px; }
.contact-card .remove{
  position:absolute; top:12px; right:12px; background:none; border:none; color: var(--text-muted); padding:4px;
}
.contact-card .remove:hover{ color: var(--danger); }
.add-field-btn{
  display:flex; align-items:center; gap:6px; background: var(--surface-2); border:none; border-radius:8px;
  padding:9px 12px; font-size:12.5px; color: var(--text-muted); margin-bottom:16px;
}
.add-field-btn:hover{ color: var(--accent); }

/* recovery code reveal-once screen */
.recovery-code-box{
  font-family:"IBM Plex Mono", monospace; font-size:16px; letter-spacing:.04em; text-align:center;
  background: var(--surface); border:1px solid var(--border); border-radius:12px; padding:18px 14px;
  margin-bottom:14px; word-spacing:6px; line-height:1.8;
}
.checkbox-row{
  display:flex; align-items:flex-start; gap:10px; background: var(--surface); border:1px solid var(--border);
  border-radius:12px; padding:13px 14px; margin-bottom:16px; font-size:13px; color: var(--text);
}
.checkbox-row input[type="checkbox"]{ margin-top:2px; width:16px; height:16px; accent-color: var(--accent); flex-shrink:0; }

/* callouts (warn / danger informational boxes) */
.callout{
  display:flex; gap:10px; border-radius:12px; padding:13px 14px; margin-bottom:16px; font-size:12.5px; line-height:1.55;
}
.callout svg{ flex-shrink:0; margin-top:1px; }
.callout.warn{ background: var(--warn-soft); color: var(--warn); }
.callout.danger{ background: var(--danger-soft); color: var(--danger); }

.settings-group{ margin-bottom: 22px; }
.settings-row{
  display:flex; align-items:center; gap:12px; background: var(--surface); border:1px solid var(--border);
  border-radius:12px; padding:13px 14px; margin-bottom:8px;
}
.settings-row .row-main{ font-size:13.5px; }
.settings-row .row-sub{ margin-top:2px; }

@media (min-width: 640px){
  .app-content{ max-width: 480px; margin: 0 auto; }
}
