/* ============================================================
   DIGITALKIT — app-style.css  (Responsive Edition)
   Editorial Minimal · Clean White · Professional
   Font: Noto Sans Thai + DM Mono
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+Thai:wght@400;500;600;700;800&family=DM+Mono:wght@400;500&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── TOKENS ── */
:root {
  --bg:          #ffffff;
  --bg2:         #fafafa;
  --bg3:         #f4f4f5;
  --surface:     #ffffff;
  --border:      #e4e4e7;
  --border2:     #d4d4d8;
  --text:        #09090b;
  --text2:       #3f3f46;
  --dim:         #71717a;
  --dim2:        #a1a1aa;
  --accent:      #09090b;
  --accent-inv:  #ffffff;
  --accent-s:    rgba(9,9,11,0.06);
  --green:       #16a34a;
  --green-s:     rgba(22,163,74,0.1);
  --red:         #dc2626;
  --red-s:       rgba(220,38,38,0.08);
  --orange:      #ea580c;
  --nav-h:       57px;
  --r:           10px;
  --r-lg:        14px;
  --r-xl:        18px;
  --sh-sm:       0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --sh:          0 4px 16px rgba(0,0,0,0.06), 0 1px 4px rgba(0,0,0,0.04);
  --sh-hover:    0 8px 28px rgba(0,0,0,0.08), 0 2px 8px rgba(0,0,0,0.04);
  --t:           .16s cubic-bezier(.4,0,.2,1);
}

[data-theme="dark"] {
  --bg:          #09090b;
  --bg2:         #111113;
  --bg3:         #18181b;
  --surface:     #111113;
  --border:      #27272a;
  --border2:     #3f3f46;
  --text:        #fafafa;
  --text2:       #e4e4e7;
  --dim:         #a1a1aa;
  --dim2:        #71717a;
  --accent:      #fafafa;
  --accent-inv:  #09090b;
  --accent-s:    rgba(250,250,250,0.07);
  --green:       #22c55e;
  --green-s:     rgba(34,197,94,0.1);
  --red:         #f87171;
  --red-s:       rgba(248,113,113,0.1);
  --sh-sm:       0 1px 3px rgba(0,0,0,0.3);
  --sh:          0 4px 16px rgba(0,0,0,0.4);
  --sh-hover:    0 8px 28px rgba(0,0,0,0.5);
}

html { scroll-behavior: smooth; }

body {
  font-family: 'Noto Sans Thai', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  transition: background var(--t), color var(--t);
}

/* ══════════════════════════════════════════
   TOP NAV
   ══════════════════════════════════════════ */
.top-nav {
  position: sticky; top: 0; z-index: 100;
  height: var(--nav-h);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 1.5rem;
  background: rgba(255,255,255,0.88);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  border-bottom: 0.5px solid var(--border);
  transition: background var(--t), border-color var(--t);
}
[data-theme="dark"] .top-nav { background: rgba(9,9,11,0.88); }

.nav-logo {
  display: flex; align-items: center; gap: 9px;
  font-size: 15px; font-weight: 700; letter-spacing: -.3px;
  color: var(--text); text-decoration: none;
  flex-shrink: 0;
}
.nav-logo-icon {
  width: 28px; height: 28px; border-radius: 7px;
  background: var(--accent);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  transition: transform var(--t);
}
.nav-logo:hover .nav-logo-icon { transform: scale(1.06); }

.nav-right {
  display: flex; align-items: center; gap: 6px;
  flex-shrink: 0; overflow: hidden;
}

.key-badge {
  font-family: 'DM Mono', monospace;
  font-size: 10px; font-weight: 500; letter-spacing: 1.5px;
  background: var(--bg3); border: 0.5px solid var(--border2);
  padding: 4px 11px; border-radius: 6px; color: var(--dim2);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 160px;
}

/* Theme switch */
.ts-btn {
  display: flex; align-items: center; gap: 6px;
  background: var(--bg2); border: 0.5px solid var(--border);
  border-radius: 99px; padding: 5px 10px;
  cursor: pointer; outline: none;
  transition: border-color var(--t), background var(--t);
  flex-shrink: 0;
}
.ts-btn:hover { border-color: var(--border2); background: var(--bg3); }
.ts-icon { font-size: 11px; user-select: none; transition: opacity var(--t); }
[data-theme="dark"]  .ts-icon.sun  { opacity: .3; }
[data-theme="light"] .ts-icon.moon { opacity: .3; }
.ts-track {
  width: 26px; height: 15px; border-radius: 99px;
  background: var(--border2); position: relative; flex-shrink: 0;
  transition: background .25s;
}
[data-theme="dark"] .ts-track { background: var(--text); }
.ts-thumb {
  position: absolute; top: 2px; left: 2px;
  width: 11px; height: 11px; border-radius: 50%;
  background: var(--bg); border: 0.5px solid rgba(0,0,0,0.1);
  transition: transform .25s cubic-bezier(.34,1.56,.64,1);
}
[data-theme="dark"] .ts-thumb { transform: translateX(11px); }

.logout-btn {
  font-family: 'Noto Sans Thai', system-ui, sans-serif;
  font-size: 12px; font-weight: 600;
  background: transparent; border: 0.5px solid var(--border);
  padding: 5px 13px; border-radius: 7px;
  cursor: pointer; color: var(--dim2); transition: all var(--t);
  white-space: nowrap; flex-shrink: 0;
}
.logout-btn:hover { border-color: var(--red); color: var(--red); background: var(--red-s); }

/* ══════════════════════════════════════════
   APP WRAP
   ══════════════════════════════════════════ */
.app-wrap {
  width: 100%; max-width: 860px;
  margin: 0 auto; padding: 2rem 1.25rem 6rem;
}

/* ══════════════════════════════════════════
   LOCK SCREEN  — Two-column layout on wide, single-column on mobile
   ══════════════════════════════════════════ */
body.is-locked { overflow: hidden; }

#lock-screen {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  overflow-y: auto;
  animation: fadeUp .4s cubic-bezier(.22,1,.36,1) both;
  transition: background var(--t);
}

/* กล่องครอบหลัก */
.lock-box {
  width: 100%;
  max-width: 900px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.lock-logo {
  display: flex; align-items: center; justify-content: center;
  gap: 10px; margin-bottom: 2rem;
}
.lock-logo-icon {
  width: 44px; height: 44px; border-radius: 11px;
  background: var(--accent);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}
.lock-logo-text {
  font-size: 21px; font-weight: 800; letter-spacing: -.5px; color: var(--text);
}

/* ── Two-column layout wrapper ── */
.lock-main-row {
  width: 100%;
  display: flex;
  align-items: stretch;
  gap: 0;
  background: var(--surface);
  border: 0.5px solid var(--border2);
  border-radius: var(--r-xl);
  box-shadow: var(--sh);
  overflow: hidden;
  position: relative;
}
.lock-main-row::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, transparent, var(--border2), transparent);
  opacity: .6; z-index: 1;
}

/* ── Left: form card ── */
.lock-card {
  flex: 1 1 320px;
  min-width: 0;
  padding: 2.75rem 2.5rem;
  position: relative;
  transition: background var(--t), border-color var(--t);
}

.lock-badge {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--bg3); border: 0.5px solid var(--border);
  color: var(--dim2); font-family: 'DM Mono', monospace;
  font-size: 10px; font-weight: 500; letter-spacing: 1.2px;
  text-transform: uppercase; padding: 4px 12px; border-radius: 6px;
  margin-bottom: 1.4rem;
}

.lock-card h1 {
  font-size: 22px; font-weight: 800; margin-bottom: .5rem;
  color: var(--text); letter-spacing: -.4px;
}
.lock-card > p {
  font-size: 14px; color: var(--dim); line-height: 1.75; margin-bottom: 2.25rem;
}

.input-wrap { display: flex; flex-direction: column; gap: 10px; }

#key-input {
  font-family: 'DM Mono', monospace;
  width: 100%; padding: 14px 16px;
  font-size: 15px; font-weight: 500; letter-spacing: 4px;
  text-transform: uppercase; text-align: center;
  background: var(--bg2); border: 0.5px solid var(--border2);
  border-radius: var(--r); color: var(--text); outline: none;
  transition: border-color var(--t), box-shadow var(--t), background var(--t);
}
#key-input::placeholder { color: var(--dim2); letter-spacing: 1px; font-size: 12px; font-weight: 400; }
#key-input:focus  { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-s); background: var(--surface); }
#key-input.error  { border-color: var(--red);   box-shadow: 0 0 0 3px var(--red-s); }
#key-input.success{ border-color: var(--green); box-shadow: 0 0 0 3px var(--green-s); }

#submit-btn {
  font-family: 'Noto Sans Thai', system-ui, sans-serif;
  width: 100%; padding: 14px;
  background: var(--accent); color: var(--accent-inv);
  font-size: 15px; font-weight: 700; letter-spacing: -.1px;
  border: none; border-radius: var(--r); cursor: pointer;
  transition: all var(--t); box-shadow: var(--sh-sm);
}
#submit-btn:hover    { opacity: .85; transform: translateY(-1px); box-shadow: var(--sh); }
#submit-btn:active   { transform: translateY(0); }
#submit-btn:disabled { background: var(--bg3); color: var(--dim2); cursor: not-allowed; transform: none; box-shadow: none; }

#msg { font-size: 13px; margin-top: 9px; min-height: 20px; text-align: center; }
#msg.error   { color: var(--red); }
#msg.success { color: var(--green); }
#msg.loading { color: var(--dim2); }

/* ── Right: preview panel ── */
.lock-preview {
  flex: 0 0 340px;
  background: var(--bg2);
  border-left: 0.5px solid var(--border);
  padding: 2rem 1.75rem;
  display: flex;
  flex-direction: column;
  gap: 10px;
  justify-content: center;
  position: relative;
  overflow: hidden;
}
[data-theme="dark"] .lock-preview { background: var(--bg3); }

.lock-preview::after {
  content: '';
  position: absolute; bottom: -60px; right: -60px;
  width: 180px; height: 180px;
  background: radial-gradient(circle, var(--accent-s) 0%, transparent 70%);
  pointer-events: none;
}

.lock-preview-title {
  font-size: 11px; font-weight: 700; letter-spacing: 1px;
  text-transform: uppercase; color: var(--dim2);
  margin-bottom: 4px;
}

/* Mini feature cards inside preview */
.preview-feat {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface);
  border: 0.5px solid var(--border);
  border-radius: var(--r);
  padding: 10px 12px;
  box-shadow: var(--sh-sm);
  animation: slideIn .4s cubic-bezier(.22,1,.36,1) both;
  transition: background var(--t), border-color var(--t);
}
.preview-feat:nth-child(2) { animation-delay: .05s; }
.preview-feat:nth-child(3) { animation-delay: .10s; }
.preview-feat:nth-child(4) { animation-delay: .15s; }
.preview-feat:nth-child(5) { animation-delay: .20s; }

@keyframes slideIn {
  from { opacity: 0; transform: translateX(16px); }
  to   { opacity: 1; transform: translateX(0); }
}

.preview-feat-icon {
  width: 32px; height: 32px; border-radius: 8px;
  background: var(--bg3); border: 0.5px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.preview-feat-icon svg { width: 16px; height: 16px; flex-shrink: 0; }
.preview-feat-body { min-width: 0; }
.preview-feat-name {
  font-size: 12px; font-weight: 700; color: var(--text);
  margin-bottom: 1px; white-space: nowrap;
}
.preview-feat-desc {
  font-size: 11px; color: var(--dim2); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}

/* Animated progress bar in preview */
.preview-bar-wrap { margin-top: 4px; }
.preview-bar-label {
  display: flex; justify-content: space-between;
  font-size: 10px; color: var(--dim2); margin-bottom: 5px;
}
.preview-bar-track {
  height: 4px; background: var(--border);
  border-radius: 99px; overflow: hidden;
}
.preview-bar-fill {
  height: 100%; border-radius: 99px;
  background: var(--accent);
  width: 0%;
  transition: width 1.4s cubic-bezier(.22,1,.36,1);
}

/* ── Footer link ── */
.lock-footer { margin-top: 1.75rem; text-align: center; font-size: 13px; }
.lock-footer a { color: var(--dim2); font-weight: 600; text-decoration: none; transition: color var(--t); }
.lock-footer a:hover { color: var(--text); }

/* ══════════════════════════════════════════
   CONTENT SCREEN
   ══════════════════════════════════════════ */
#content-screen { display: none; animation: fadeUp .35s cubic-bezier(.22,1,.36,1) both; width: 100%; }

/* ── TABS ── */
.tabs {
  display: flex; gap: 3px; margin-bottom: 1.1rem;
  background: var(--bg2); border: 0.5px solid var(--border);
  border-radius: var(--r-lg); padding: 4px; flex-wrap: wrap;
  box-shadow: var(--sh-sm);
}
.tab-btn {
  font-family: 'Noto Sans Thai', system-ui, sans-serif;
  font-size: 13px; font-weight: 600;
  padding: 8px 16px; border-radius: var(--r); border: none;
  background: transparent; cursor: pointer; color: var(--dim);
  transition: all var(--t); flex: 1; min-width: 0;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  letter-spacing: -.1px; white-space: nowrap;
}
.tab-btn:hover  { color: var(--text); background: var(--bg3); }
.tab-btn.active {
  background: var(--surface); color: var(--text);
  box-shadow: var(--sh-sm);
  border: 0.5px solid var(--border);
}
.tab-btn svg { opacity: .6; transition: opacity var(--t); }
.tab-btn.active svg, .tab-btn:hover svg { opacity: 1; }

/* ── PANELS ── */
.tab-panel {
  display: none;
  background: var(--surface); border: 0.5px solid var(--border);
  border-radius: var(--r-xl); padding: 2rem 1.875rem;
  animation: fadeUp .25s cubic-bezier(.22,1,.36,1) both;
  box-shadow: var(--sh-sm);
  transition: background var(--t), border-color var(--t);
}
.tab-panel.active { display: block; }

.panel-header {
  margin-bottom: 1.75rem; padding-bottom: 1.25rem;
  border-bottom: 0.5px solid var(--border);
}
.panel-header h2 {
  font-size: 18px; font-weight: 800; margin-bottom: 3px;
  color: var(--text); display: flex; align-items: center; gap: 8px;
  letter-spacing: -.3px;
}
.panel-header p { font-size: 12px; color: var(--dim2); margin-left: 26px; }

/* ── SHARED INPUTS ── */
.form-input {
  background: var(--bg2); border: 0.5px solid var(--border2);
  border-radius: var(--r); color: var(--text);
  font-family: 'Noto Sans Thai', system-ui, sans-serif; font-size: 13px;
  padding: 10px 13px; outline: none;
  transition: border-color var(--t), box-shadow var(--t), background var(--t);
  width: 100%;
}
.form-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-s);
  background: var(--surface);
}
.form-input::placeholder { color: var(--dim2); }
select.form-input { cursor: pointer; }

.btn-add {
  padding: 10px 18px;
  background: var(--accent); color: var(--accent-inv);
  border: none; border-radius: var(--r);
  font-family: 'Noto Sans Thai', system-ui, sans-serif;
  font-size: 13px; font-weight: 700;
  cursor: pointer; white-space: nowrap; flex-shrink: 0;
  transition: opacity var(--t), transform var(--t), box-shadow var(--t);
  box-shadow: var(--sh-sm);
}
.btn-add:hover  { opacity: .85; transform: translateY(-1px); box-shadow: var(--sh); }
.btn-add:active { transform: translateY(0); }

.btn-icon {
  background: none; border: none; color: var(--dim2);
  font-size: 11px; cursor: pointer; padding: 5px 7px; border-radius: 6px;
  transition: color var(--t), background var(--t); line-height: 1; flex-shrink: 0;
}
.btn-icon:hover { color: var(--red); background: var(--red-s); }

/* ── EMPTY STATE ── */
.empty-state {
  text-align: center; padding: 3rem 1rem; color: var(--dim2);
  display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.empty-state-icon { font-size: 28px; opacity: .3; }
.empty-state-text { font-size: 13px; font-weight: 500; }

/* ── ANIMATIONS ── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ══════════════════════════════════════════
   RESPONSIVE — Desktop first breakdown
   ══════════════════════════════════════════ */

/* ── iPad / Tablet (≤ 900px) ── */
@media (max-width: 900px) {
  .lock-preview { flex: 0 0 280px; }
}

/* ── Small tablet / Large phone (≤ 720px) ── */
@media (max-width: 720px) {
  /* Lock screen: stack vertically */
  .lock-main-row {
    flex-direction: column;
  }
  .lock-preview {
    flex: none;
    border-left: none;
    border-top: 0.5px solid var(--border);
    padding: 1.5rem;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 8px;
  }
  .lock-preview-title { width: 100%; margin-bottom: 0; }
  .preview-feat { flex: 1 1 calc(50% - 4px); min-width: 140px; }
  .preview-bar-wrap { width: 100%; }

  /* Nav */
  .key-badge { display: none; }
  .top-nav { padding: 0 1rem; }
  .app-wrap { padding: 1.25rem .875rem 5rem; }
  .tab-panel { padding: 1.5rem 1.1rem; }
  .tabs { gap: 2px; padding: 3px; }
  .tab-btn { font-size: 12px; padding: 8px 10px; }
}

/* ── Mobile (≤ 480px) ── */
@media (max-width: 480px) {
  #lock-screen { padding: 1rem; }
  .lock-logo { margin-bottom: 1.25rem; }
  .lock-logo-icon { width: 36px; height: 36px; }
  .lock-logo-text { font-size: 18px; }
  .lock-card { padding: 1.75rem 1.25rem; }
  .lock-card h1 { font-size: 19px; }

  /* Preview: single column on mobile */
  .lock-preview {
    flex-direction: column;
    padding: 1.25rem;
  }
  .preview-feat { flex: none; width: 100%; }

  /* Nav: hide label text on tabs, show only icons */
  .tab-btn { font-size: 0; gap: 0; padding: 10px 8px; }
  .tab-btn svg { font-size: 16px; opacity: .7; width: 17px; height: 17px; }
  .tab-btn.active svg { opacity: 1; }

  /* Panels */
  .tab-panel { padding: 1.25rem .875rem; }
  .panel-header h2 { font-size: 16px; }
}

/* ── Very small (≤ 360px) ── */
@media (max-width: 360px) {
  .lock-card { padding: 1.5rem 1rem; }
  #key-input { font-size: 13px; letter-spacing: 2px; }
  .app-wrap { padding: 1rem .625rem 5rem; }
}