/* ── Variables ──────────────────────────────────────────────── */
:root {
  --font: 'Vazirmatn', system-ui, sans-serif;
  --radius: 14px;
  --radius-sm: 8px;
  --transition: 0.2s ease;
}

[data-theme="dark"] {
  --bg:           #0d0d10;
  --bg-card:      #17171d;
  --bg-input:     #1f1f27;
  --bg-hover:     #242430;
  --border:       #2a2a38;
  --border-focus: #6c63ff;
  --text:         #e8e8f0;
  --text-muted:   #7a7a9a;
  --text-dim:     #4a4a60;
  --accent:       #6c63ff;
  --accent-glow:  rgba(108,99,255,0.18);
  --accent-2:     #a78bfa;
  --success:      #34d399;
  --error-bg:     rgba(239,68,68,0.12);
  --error-text:   #f87171;
  --grain-opacity: 0.04;
  --shadow:       0 4px 24px rgba(0,0,0,0.4);
  --shadow-card:  0 2px 12px rgba(0,0,0,0.3);
}

[data-theme="light"] {
  --bg:           #f5f5fa;
  --bg-card:      #ffffff;
  --bg-input:     #f0f0f8;
  --bg-hover:     #ebebf5;
  --border:       #e0e0ec;
  --border-focus: #6c63ff;
  --text:         #1a1a2e;
  --text-muted:   #6b6b8a;
  --text-dim:     #b0b0c8;
  --accent:       #6c63ff;
  --accent-glow:  rgba(108,99,255,0.10);
  --accent-2:     #7c3aed;
  --success:      #059669;
  --error-bg:     rgba(220,38,38,0.08);
  --error-text:   #dc2626;
  --grain-opacity: 0.025;
  --shadow:       0 4px 24px rgba(108,99,255,0.08);
  --shadow-card:  0 2px 12px rgba(0,0,0,0.06);
}

/* ── Reset ──────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background var(--transition), color var(--transition);
  -webkit-font-smoothing: antialiased;
}

/* ── Grain texture ──────────────────────────────────────────── */
.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: var(--grain-opacity);
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 512 512' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 200px 200px;
}

/* ── Header ─────────────────────────────────────────────────── */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.logo, .logo-link {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  text-decoration: none;
  color: var(--text);
}
.logo-icon { font-size: 1.2rem; }
.logo-text {
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.theme-toggle {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 36px; height: 36px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background var(--transition), border-color var(--transition);
  color: var(--text-muted);
  font-size: 1rem;
}
.theme-toggle:hover { background: var(--bg-hover); border-color: var(--accent); }

[data-theme="dark"]  .theme-icon::after { content: "☀️"; }
[data-theme="light"] .theme-icon::after { content: "🌙"; }

/* ── Main layout ────────────────────────────────────────────── */
.main {
  flex: 1;
  width: 100%;
  max-width: 680px;
  margin: 0 auto;
  padding: 2.5rem 1.25rem 3rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  position: relative;
  z-index: 1;
}

/* ── Hero ───────────────────────────────────────────────────── */
.hero {
  text-align: center;
  padding: 1rem 0 0.5rem;
}
.hero-title {
  font-size: clamp(1.5rem, 4vw, 2rem);
  font-weight: 700;
  line-height: 1.35;
  letter-spacing: -0.02em;
  color: var(--text);
}
.hero-title .accent {
  color: var(--accent);
  position: relative;
}
.hero-sub {
  margin-top: 0.75rem;
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.7;
}

/* ── Card ───────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem;
  box-shadow: var(--shadow-card);
  transition: background var(--transition), border-color var(--transition);
}

.center-card {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

/* ── Form fields ────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 0.5rem; margin-bottom: 1.25rem; }
.field:last-of-type { margin-bottom: 0; }

.label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

.textarea {
  background: var(--bg-input);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: 'Courier New', 'Consolas', monospace;
  font-size: 0.82rem;
  line-height: 1.6;
  padding: 0.9rem 1rem;
  resize: vertical;
  width: 100%;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  direction: ltr;
  text-align: left;
}
.textarea:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.textarea::placeholder { color: var(--text-dim); font-size: 0.78rem; }

.field-hint {
  font-size: 0.75rem;
  color: var(--text-dim);
  text-align: left;
}

/* ── PIN input ──────────────────────────────────────────────── */
.field-pin { align-items: stretch; }

.pin-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.pin-input {
  background: var(--bg-input);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font);
  font-size: 1.4rem;
  letter-spacing: 0.4em;
  padding: 0.75rem 3rem 0.75rem 1rem;
  width: 100%;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  direction: ltr;
  text-align: center;
}
.pin-input-lg { font-size: 1.8rem; letter-spacing: 0.6em; padding: 1rem 3rem 1rem 1rem; }
.pin-input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.pin-input::placeholder { letter-spacing: 0.3em; color: var(--text-dim); font-size: 1rem; }

.pin-toggle {
  position: absolute;
  left: 0.75rem;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  display: flex; align-items: center;
  padding: 0.25rem;
  border-radius: 4px;
  transition: color var(--transition);
}
.pin-toggle:hover { color: var(--accent); }

.pin-dots {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  margin-top: 0.25rem;
}
.pin-dots span {
  width: 10px; height: 10px;
  border-radius: 50%;
  border: 2px solid var(--border);
  transition: all 0.15s ease;
}
.pin-dots span.filled {
  background: var(--accent);
  border-color: var(--accent);
  transform: scale(1.2);
}

/* ── Buttons ────────────────────────────────────────────────── */
.btn-primary {
  width: 100%;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.95rem;
  font-weight: 600;
  padding: 0.85rem 1.5rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 1.25rem;
  transition: opacity var(--transition), transform var(--transition), box-shadow var(--transition);
  box-shadow: 0 4px 16px rgba(108,99,255,0.35);
}
.btn-primary:hover { opacity: 0.88; box-shadow: 0 6px 20px rgba(108,99,255,0.45); transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }
.btn-primary.inline-btn { width: auto; padding: 0.75rem 2rem; margin-top: 1rem; }

.btn-secondary {
  background: var(--bg-input);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.85rem;
  font-weight: 500;
  padding: 0.6rem 1.25rem;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition);
}
.btn-secondary:hover { background: var(--bg-hover); border-color: var(--accent); }

/* ── Result box ─────────────────────────────────────────────── */
.result {
  margin-top: 1.25rem;
  background: var(--accent-glow);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 1.1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.result-label { font-size: 0.8rem; color: var(--accent); font-weight: 600; }
.result-url-wrap { display: flex; align-items: center; gap: 0.5rem; }
.result-url {
  font-size: 0.85rem;
  color: var(--text);
  word-break: break-all;
  direction: ltr;
  text-decoration: none;
  font-family: 'Courier New', monospace;
  flex: 1;
}
.result-url:hover { color: var(--accent); }
.result-expire { font-size: 0.75rem; color: var(--text-muted); }

.copy-btn {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.35rem;
  cursor: pointer;
  color: var(--text-muted);
  display: flex; align-items: center;
  flex-shrink: 0;
  transition: all var(--transition);
}
.copy-btn:hover { color: var(--accent); border-color: var(--accent); }

/* ── Error ──────────────────────────────────────────────────── */
.error {
  background: var(--error-bg);
  color: var(--error-text);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  font-size: 0.85rem;
  border: 1px solid rgba(239,68,68,0.2);
}

/* ── Features row ───────────────────────────────────────────── */
.features {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  flex-wrap: wrap;
}
.feature {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.78rem;
  color: var(--text-muted);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 50px;
  padding: 0.4rem 0.9rem;
}
.feature-icon { font-size: 0.85rem; }

/* ── State icons ────────────────────────────────────────────── */
.state-icon { font-size: 2.5rem; margin-bottom: 0.25rem; }
.state-title { font-size: 1.2rem; font-weight: 700; }
.state-desc { font-size: 0.88rem; color: var(--text-muted); line-height: 1.6; max-width: 320px; }

/* ── Content card ───────────────────────────────────────────── */
.content-card { padding: 0; overflow: hidden; }

.content-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 0.75rem;
}

.content-badge {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--success);
  background: rgba(52,211,153,0.1);
  padding: 0.3rem 0.75rem;
  border-radius: 50px;
  border: 1px solid rgba(52,211,153,0.25);
}

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

.action-btn {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-family: var(--font);
  font-size: 0.78rem;
  font-weight: 500;
  padding: 0.4rem 0.8rem;
  cursor: pointer;
  transition: all var(--transition);
}
.action-btn:hover { color: var(--text); border-color: var(--accent); background: var(--accent-glow); }
.action-btn-qr:hover { color: var(--accent); }

.note-content {
  padding: 1.25rem;
  font-family: 'Courier New', 'Consolas', monospace;
  font-size: 0.82rem;
  line-height: 1.7;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-all;
  direction: ltr;
  text-align: left;
  max-height: 400px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

/* ── QR Panel ───────────────────────────────────────────────── */
.qr-panel {
  border-top: 1px solid var(--border);
  background: var(--bg-input);
  border-radius: 0 0 var(--radius) var(--radius);
}
.qr-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1.25rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}
.qr-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 1rem;
  padding: 0.25rem;
  border-radius: 4px;
  transition: color var(--transition);
}
.qr-close:hover { color: var(--text); }
.qr-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1.5rem;
  gap: 0.75rem;
}
.qr-canvas {
  background: #fff;
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
}
.qr-canvas img, .qr-canvas canvas { display: block; }
.qr-hint { font-size: 0.78rem; color: var(--text-muted); }

/* ── Expire card ────────────────────────────────────────────── */
.expire-card {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.82rem;
  color: var(--text-muted);
  padding: 0.85rem 1.25rem;
  justify-content: center;
}
.expire-icon { font-size: 1rem; }

/* ── Footer ─────────────────────────────────────────────────── */
.footer {
  text-align: center;
  padding: 1rem;
  font-size: 0.75rem;
  color: var(--text-dim);
  border-top: 1px solid var(--border);
  position: relative;
  z-index: 1;
}

/* ── Toast ──────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(1rem);
  background: var(--text);
  color: var(--bg);
  padding: 0.65rem 1.25rem;
  border-radius: 50px;
  font-size: 0.85rem;
  font-weight: 500;
  z-index: 9999;
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.2s ease;
  white-space: nowrap;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── Shake animation ────────────────────────────────────────── */
@keyframes shake {
  0%,100% { transform: translateX(0); }
  20%      { transform: translateX(-8px); }
  40%      { transform: translateX(8px); }
  60%      { transform: translateX(-5px); }
  80%      { transform: translateX(5px); }
}
.shake { animation: shake 0.45s ease; }

/* ── Utility ────────────────────────────────────────────────── */
.hidden { display: none !important; }

/* ── Scrollbar ──────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 480px) {
  .main { padding: 1.5rem 1rem 2rem; }
  .card { padding: 1.25rem; }
  .content-header { flex-direction: column; align-items: flex-start; }
  .hero-title { font-size: 1.35rem; }
  .features { gap: 0.5rem; }
  .feature { font-size: 0.72rem; padding: 0.35rem 0.7rem; }
  .pin-input-lg { font-size: 1.4rem; letter-spacing: 0.4em; }
}

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