/* ============================================================
   Telegram Mini App — Global Styles
   Uses Telegram WebApp CSS variables for theme compatibility
   ============================================================ */

:root {
  --bg:       var(--tg-theme-bg-color,          #18181b);
  --surface:  var(--tg-theme-secondary-bg-color, #27272a);
  --card:     var(--tg-theme-secondary-bg-color, #27272a);
  --text:     var(--tg-theme-text-color,         #fafafa);
  --muted:    var(--tg-theme-hint-color,         #a1a1aa);
  --accent:   var(--tg-theme-button-color,       #6366f1);
  --accent-t: var(--tg-theme-button-text-color,  #ffffff);
  --link:     var(--tg-theme-link-color,         #818cf8);
  --border:   rgba(255,255,255,0.08);
}

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

html { height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding-bottom: env(safe-area-inset-bottom, 0);
  font-size: 15px;
  line-height: 1.5;
}

/* ── Loading overlay ─────────────────────────────────────── */
#loading {
  position: fixed; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  background: var(--bg); z-index: 999; gap: 16px;
  color: var(--muted);
}

.spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

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

#app {
  display: flex; flex-direction: column;
  min-height: 100vh;
  padding-bottom: 64px; /* room for tab-bar */
}

/* ── App Header ──────────────────────────────────────────── */
.app-header {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px 10px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}

.avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .9rem; color: var(--accent-t);
  flex-shrink: 0;
  overflow: hidden;
}

.avatar img { width: 100%; height: 100%; object-fit: cover; }

.header-info {
  display: flex; flex-direction: column; gap: 2px;
  font-weight: 600; font-size: .95rem;
}

.badge {
  font-size: .65rem; font-weight: 700;
  background: linear-gradient(135deg, #f59e0b, #fbbf24);
  color: #000; border-radius: 4px; padding: 1px 6px;
  width: fit-content;
}

/* ── Tab bar ─────────────────────────────────────────────── */
.tab-bar {
  position: fixed; bottom: 0; left: 0; right: 0;
  display: flex; background: var(--surface);
  border-top: 1px solid var(--border);
  z-index: 20;
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.tab {
  flex: 1; padding: 10px 4px; border: none;
  background: transparent; color: var(--muted);
  font-size: .72rem; cursor: pointer;
  transition: color .2s, background .2s;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.tab:hover   { color: var(--text); }
.tab.active  { color: var(--accent); background: rgba(99,102,241,.08); }

/* ── Tab content ─────────────────────────────────────────── */
.tab-content { padding: 16px; display: flex; flex-direction: column; gap: 12px; }

/* ── Card ────────────────────────────────────────────────── */
.card {
  background: var(--card);
  border-radius: 14px;
  padding: 16px;
  border: 1px solid var(--border);
}

.card h2 { font-size: 1.1rem; margin-bottom: 4px; }
.card h3 { font-size: .95rem; margin-bottom: 10px; color: var(--muted); font-weight: 600; }

/* ── Info grid ───────────────────────────────────────────── */
.info-grid  { display: flex; flex-direction: column; gap: 10px; }
.info-item  { display: flex; justify-content: space-between; align-items: center; }
.info-label { color: var(--muted); font-size: .8rem; }
.info-val   { font-weight: 600; font-size: .85rem; }

/* ── Form elements ───────────────────────────────────────── */
textarea, input[type="text"], input[type="number"] {
  width: 100%; padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: .9rem;
  font-family: inherit;
  resize: vertical;
  margin-bottom: 10px;
  outline: none;
  transition: border-color .2s;
}
textarea:focus, input:focus { border-color: var(--accent); }

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  width: 100%; padding: 13px;
  border: none; border-radius: 12px;
  font-size: .95rem; font-weight: 600;
  cursor: pointer; transition: opacity .15s, transform .1s;
}
.btn:active { opacity: .8; transform: scale(.98); }

.btn.primary   { background: var(--accent); color: var(--accent-t); }
.btn.secondary { background: var(--border); color: var(--text); }
.btn.gold      { background: linear-gradient(135deg, #f59e0b, #fbbf24); color: #000; }
.btn:disabled  { opacity: .5; cursor: not-allowed; }

/* ── Feedback line ───────────────────────────────────────── */
.feedback { font-size: .8rem; text-align: center; margin-top: 8px; padding: 6px; border-radius: 8px; }
.feedback.ok  { color: #34d399; background: rgba(52,211,153,.1); }
.feedback.err { color: #f87171; background: rgba(248,113,113,.1); }

/* ── Premium card ────────────────────────────────────────── */
.premium-card { text-align: center; }
.stars-icon   { font-size: 3rem; margin-bottom: 8px; }
.premium-card h2 { margin-bottom: 8px; }
.premium-card p  { color: var(--muted); margin-bottom: 14px; }

.perks { list-style: none; text-align: left; margin: 12px 0 18px; display: flex; flex-direction: column; gap: 6px; }
.perks li { font-size: .9rem; }

.price-tag {
  font-size: 1.4rem; font-weight: 700;
  color: #fbbf24; margin-bottom: 14px;
}

.small  { font-size: .75rem; }
.muted  { color: var(--muted); font-size: .85rem; }

/* ── Notes list ──────────────────────────────────────────── */
.note-item {
  background: var(--card); border-radius: 12px;
  padding: 12px 14px; border: 1px solid var(--border);
  display: flex; gap: 10px; align-items: flex-start;
}
.note-body { flex: 1; font-size: .9rem; white-space: pre-wrap; word-break: break-word; }
.note-meta { font-size: .72rem; color: var(--muted); margin-top: 4px; }
.note-del  {
  background: none; border: none; color: var(--muted);
  cursor: pointer; font-size: 1.1rem; line-height: 1;
  padding: 2px 4px; border-radius: 6px; flex-shrink: 0;
}
.note-del:hover { color: #f87171; }

/* Scrollable areas */
.scroll-area { overflow-x: auto; }
