/* =====================================================
   reserve.css — reserve codes page (redesign)
   ===================================================== */

:root {
  --bg: #08090c;
  --bg-gradient-top: #142042;
  --bg-elevated: rgba(255, 255, 255, 0.03);
  --bg-elevated-hover: rgba(255, 255, 255, 0.05);
  --bg-input: rgba(255, 255, 255, 0.025);

  --border: rgba(255, 255, 255, 0.06);
  --border-strong: rgba(255, 255, 255, 0.12);

  --text: #f5f6f8;
  --text-muted: #8a92a8;
  --text-dim: #4f6080;

  --gold: #d4af6a;
  --gold-bright: #e8c47e;
  --gold-dim: rgba(212, 175, 106, 0.15);
  --blue: #4a7cff;
  --blue-bright: #6b94ff;
  --blue-dim: rgba(74, 124, 255, 0.15);
  --red-bright: #ff7878;
  --green-bright: #5ed4a3;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 14px;

  --tg-safe-area-inset-top: 0px;
  --tg-content-safe-area-inset-top: 0px;
  --tg-safe-area-inset-bottom: 0px;
  --tg-content-safe-area-inset-bottom: 0px;
  --app-safe-area-top: max(env(safe-area-inset-top, 0px), var(--tg-safe-area-inset-top, 0px), var(--tg-content-safe-area-inset-top, 0px));
  --app-safe-area-bottom: max(env(safe-area-inset-bottom, 0px), var(--tg-safe-area-inset-bottom, 0px), var(--tg-content-safe-area-inset-bottom, 0px));
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Geist', sans-serif;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "ss01", "ss02";
}

body {
  min-height: 100vh;
  display: flex;
  justify-content: center;
}

.phone {
  width: 100%;
  max-width: 420px;
  min-height: 100vh;
  background: radial-gradient(ellipse at top, var(--bg-gradient-top) 0%, var(--bg) 60%);
  position: relative;
  overflow: hidden;
  padding-bottom: 95px;
  display: flex;
  flex-direction: column;
}

.phone::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.3;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.5'/%3E%3C/svg%3E");
  z-index: 1;
}

/* ============================================
   CONTENT
   ============================================ */
.content {
  position: relative;
  z-index: 2;
  padding: 0 22px 40px;
}

/* ============================================
   PAGE HEADER
   ============================================ */
.page-header {
  margin-bottom: 22px;
  animation: fadeUp .8s ease both;
}

.page-eyebrow {
  font-size: 10px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--text-dim);
  font-weight: 600;
  margin-bottom: 8px;
}

.page-title {
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.04em;
  line-height: 1;
  color: var(--text);
}

.page-subtitle {
  margin-top: 12px;
  font-size: 12px;
  line-height: 1.55;
  color: var(--text-muted);
  max-width: 95%;
}

/* ============================================
   SECTION DIVIDER
   ============================================ */
.section-divider {
  margin: 24px 0 14px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.section-divider-line {
  flex: 1;
  height: 1px;
  background: var(--border);
}

.section-divider-text {
  font-size: 9px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--text-dim);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-divider-text .count {
  font-family: 'Geist', sans-serif;
  color: var(--gold-bright);
  font-size: 10px;
  letter-spacing: 0;
  font-weight: 500;
}

/* ============================================
   CODE CARDS
   ============================================ */
.codes-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  animation: fadeUp .8s .1s ease both;
}

.code-card {
  background: linear-gradient(160deg, rgba(255,255,255,0.055) 0%, rgba(255,255,255,0.015) 50%, rgba(255,255,255,0.005) 100%);
  border: 1px solid rgba(255,255,255,0.06);
  border-top: 1px solid rgba(255,255,255,0.14);
  border-bottom: 1px solid rgba(0,0,0,0.3);
  border-radius: var(--radius-md);
  padding: 14px 14px 14px 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  backdrop-filter: blur(20px);
  box-shadow: 0 4px 16px rgba(0,0,0,0.25), 0 1px 0 rgba(255,255,255,0.06) inset, 0 -1px 0 rgba(0,0,0,0.12) inset;
  position: relative;
  transition: all .25s;
  overflow: hidden;
}

.code-card:hover {
  background: var(--bg-elevated-hover);
  border-color: rgba(74,124,255,0.25);
}

.code-card.used { opacity: 0.6; }
.code-card.used:hover { opacity: 0.8; }

.code-num {
  font-family: 'Geist', sans-serif;
  font-size: 10px;
  color: var(--text-dim);
  font-weight: 500;
  width: 14px;
  flex-shrink: 0;
}

.code-value {
  flex: 1;
  font-family: 'Geist Mono', monospace;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.08em;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.code-status {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 9px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-weight: 700;
  padding: 4px 9px;
  border-radius: 4px;
  flex-shrink: 0;
}

.code-status.active {
  color: var(--green-bright);
  background: rgba(94, 212, 163, 0.12);
  border: 1px solid rgba(94, 212, 163, 0.25);
}

.code-status.used-badge {
  color: var(--text-dim);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
}

.code-status .dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 6px currentColor;
  flex-shrink: 0;
}

.code-status.used-badge .dot { box-shadow: none; }

.code-actions {
  background: transparent;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: color .2s;
  border-radius: 6px;
}

.code-actions:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
}

/* Slide-in action view */
.code-card .default-view,
.code-card .action-view {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
  transition: opacity .25s cubic-bezier(.2,.7,.2,1), transform .25s cubic-bezier(.2,.7,.2,1);
}

.code-card .action-view {
  position: absolute;
  left: 12px;
  right: 44px;
  top: 0;
  bottom: 0;
  justify-content: flex-end;
  opacity: 0;
  pointer-events: none;
  transform: translateX(12px);
}

.code-card.menu-open .default-view {
  opacity: 0;
  pointer-events: none;
  transform: translateX(-12px);
}

.code-card.menu-open .action-view {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(0);
}

.code-card.menu-open .code-actions { color: var(--blue-bright); }

.a-edit, .a-del {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  padding: 7px 11px;
  border-radius: 8px;
  background: rgba(255,255,255,0.06);
  color: var(--text);
  transition: background .15s;
  white-space: nowrap;
}

.a-edit {
  color: var(--blue-bright);
  background: rgba(74,124,255,0.1);
}

.a-edit:hover { background: rgba(74,124,255,0.18); }

.a-del {
  color: var(--red-bright);
  background: rgba(255,120,120,0.1);
}

.a-del:hover { background: rgba(255,120,120,0.18); }

.a-edit svg, .a-del svg {
  width: 13px;
  height: 13px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ============================================
   ADD CODE BUTTON + POPOVER
   ============================================ */
.add-code-wrap {
  margin-top: 10px;
  position: relative;
}

.add-code-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px;
  background: transparent;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-family: 'Geist', sans-serif;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: all .25s;
  animation: fadeUp .8s .15s ease both;
}

.add-code-btn:hover {
  border-color: var(--gold);
  color: var(--gold-bright);
  background: rgba(212, 175, 106, 0.05);
}

.add-code-btn svg {
  width: 14px;
  height: 14px;
  stroke-width: 2.5;
}

/* Sheet backdrop */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
  z-index: 100;
}

.sheet-backdrop.show { opacity: 1; pointer-events: auto; }

/* Add sheet popover */
.add-sheet {
  position: fixed;
  left: 14px;
  right: 14px;
  bottom: max(96px, calc(84px + var(--app-safe-area-bottom)));
  max-width: 392px;
  margin: 0 auto;
  background: rgba(18, 22, 35, 0.98);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 14px;
  padding: 12px;
  z-index: 101;
  box-shadow: 0 18px 40px rgba(0,0,0,0.6);
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition: opacity .2s, transform .25s cubic-bezier(.2,.7,.2,1);
}

.add-sheet.show { opacity: 1; pointer-events: auto; transform: translateY(0); }

.sheet-input {
  width: 100%;
  padding: 14px;
  font-family: 'Geist Mono', monospace;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.12em;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 12px;
  outline: none;
  transition: all .2s;
}

.sheet-input:focus {
  border-color: rgba(74,124,255,0.5);
  background: rgba(74,124,255,0.08);
}

.sheet-input.invalid {
  border-color: rgba(255,53,53,0.5);
  background: rgba(255,53,53,0.08);
}

.input-wrap { position: relative; }

.input-warn {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  padding: 4px 8px;
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  background: #ff3535;
  border-radius: 6px;
  letter-spacing: .02em;
  pointer-events: none;
  opacity: 0;
  transition: opacity .15s;
}

.input-warn.show { opacity: 1; }

.pop-row {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.pop-row button {
  flex: 1;
  padding: 12px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  border-radius: 10px;
  cursor: pointer;
  transition: opacity .2s;
  border: none;
}

.sheet-cancel {
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08) !important;
  color: var(--text);
}

.sheet-cancel:hover { background: rgba(255,255,255,0.08); }

.sheet-save {
  background: linear-gradient(180deg, #6a91ff 0%, #4a7cff 50%, #2f5cd8 100%);
  box-shadow: 0 1px 0 rgba(255,255,255,0.25) inset, 0 -1px 0 rgba(0,0,0,0.25) inset, 0 6px 18px rgba(74,124,255,0.35);
  color: #fff;
}

.sheet-save:disabled {
  opacity: .4;
  cursor: not-allowed;
  filter: grayscale(.6);
}

/* Delete dialog */
.del-dlg {
  position: fixed;
  left: 14px;
  right: 14px;
  bottom: max(96px, calc(84px + var(--app-safe-area-bottom)));
  max-width: 392px;
  margin: 0 auto;
  background: linear-gradient(180deg, #14182a 0%, #0a0c15 100%);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 16px;
  padding: 16px 16px 14px;
  text-align: center;
  z-index: 101;
  box-shadow: 0 18px 40px rgba(0,0,0,0.6);
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition: opacity .2s, transform .25s cubic-bezier(.2,.7,.2,1);
}

.del-dlg.show { opacity: 1; pointer-events: auto; transform: translateY(0); }

.del-title {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.01em;
  margin-bottom: 4px;
}

.del-title b {
  font-family: 'Geist Mono', monospace;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: var(--red-bright);
}

.del-sub {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
  margin-bottom: 14px;
}

.del-actions { display: flex; gap: 8px; }

.sheet-delete {
  flex: 1;
  padding: 14px;
  background: linear-gradient(180deg, #ff8a8a 0%, #ff4040 50%, #d12f2f 100%);
  border: none;
  border-radius: 12px;
  color: #fff;
  font-family: inherit;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  transition: opacity .2s;
  box-shadow: 0 1px 0 rgba(255,255,255,0.25) inset, 0 -1px 0 rgba(0,0,0,0.25) inset, 0 6px 18px rgba(255,80,80,0.4);
}

.sheet-delete:hover { opacity: .9; }

/* ============================================
   GUIDES
   ============================================ */
.guides {
  display: flex;
  flex-direction: column;
  gap: 8px;
  animation: fadeUp .8s .25s ease both;
}

.guide-card {
  background: linear-gradient(160deg, rgba(255,255,255,0.055) 0%, rgba(255,255,255,0.015) 50%, rgba(255,255,255,0.005) 100%);
  border: 1px solid rgba(255,255,255,0.06);
  border-top: 1px solid rgba(255,255,255,0.14);
  border-bottom: 1px solid rgba(0,0,0,0.3);
  border-radius: var(--radius-md);
  backdrop-filter: blur(20px);
  box-shadow: 0 4px 16px rgba(0,0,0,0.25), 0 1px 0 rgba(255,255,255,0.06) inset, 0 -1px 0 rgba(0,0,0,0.12) inset;
  transition: all .25s;
  overflow: hidden;
  cursor: pointer;
}

.guide-card:not(.expandable) {
  padding: 13px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: inherit;
}

.guide-card:not(.expandable):hover {
  background: var(--bg-elevated-hover);
  border-color: rgba(74,124,255,0.25);
}

.guide-card:not(.expandable):hover .guide-arrow {
  color: var(--gold);
  transform: translateX(3px);
}

/* Expandable guide */
.guide-card.expandable .guide-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 14px;
}

.guide-card.expandable.open .guide-arrow {
  transform: rotate(90deg);
  color: var(--blue-bright);
}

.guide-card.expandable .guide-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height .45s ease, padding .25s;
  padding: 0 14px;
}

.guide-card.expandable.open .guide-body {
  max-height: 2500px;
  padding: 0 14px 14px;
}

.guide-card.expandable.open {
  background: linear-gradient(160deg, rgba(74,124,255,0.08) 0%, rgba(255,255,255,0.015) 100%);
  border-color: rgba(74,124,255,0.25);
}

.guide-icon {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: rgba(74, 124, 255, 0.15);
  border: 1px solid rgba(74, 124, 255, 0.3);
  color: var(--blue-bright);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.guide-icon svg { width: 15px; height: 15px; }

.guide-text {
  flex: 1;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  letter-spacing: -0.01em;
}

.guide-arrow {
  color: var(--text-dim);
  flex-shrink: 0;
  transition: all .25s;
}

.guide-arrow svg { display: block; }

/* Step list */
.step-list { display: flex; flex-direction: column; gap: 6px; }

.step-item {
  display: flex;
  gap: 10px;
  padding: 10px 12px;
  background: rgba(255,255,255,0.02);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 10px;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
}

.step-item .step-n {
  width: 22px;
  height: 22px;
  border-radius: 7px;
  background: rgba(74,124,255,0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--blue-bright);
  flex-shrink: 0;
}

.step-item .step-body { flex: 1; align-self: center; }

.step-item b { color: var(--text); font-weight: 700; }

.step-item a, .step-item a b {
  color: var(--blue-bright);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.step-item .arr {
  display: inline-block;
  color: var(--text-dim);
  line-height: 1;
  position: relative;
  top: 1px;
  font-size: 13px;
  font-weight: 700;
}

.step-item.critical {
  background: linear-gradient(160deg, rgba(255,60,60,0.14), rgba(255,60,60,0.03));
  border: 1px solid rgba(255,60,60,0.4);
  align-items: flex-start;
  padding: 12px;
}

.step-item.critical .step-n {
  background: #ff3535;
  color: #fff;
  box-shadow: 0 2px 8px rgba(255,50,50,0.4);
}

.step-item.critical .crit-label {
  display: block;
  font-size: 13px;
  font-weight: 800;
  color: #ff3535;
  margin: 0 0 4px;
  line-height: 1;
}

/* ============================================
   TABBAR
   ============================================ */

/* ============================================
   EMPTY STATE
   ============================================ */
.empty-codes {
  text-align: center;
  padding: 28px 0 8px;
  animation: fadeUp .8s .1s ease both;
}

.empty-codes-icon {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: rgba(74,124,255,0.1);
  border: 1px solid rgba(74,124,255,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 12px;
  color: var(--blue-bright);
}

.empty-codes-icon svg { width: 22px; height: 22px; }

.empty-codes-text {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
}

/* ============================================
   ANIMATION
   ============================================ */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
