/* ==========================================================================
   MailVision — Тарҳи "Маркизи Синамо" (Cinema Marquee design system)
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Big+Shoulders+Display:wght@600;700;800&family=Manrope:wght@400;500;600;700;800&display=swap');

:root {
  /* Ранг — палитраи "синамо шабона" / Color — "cinema at night" palette */
  --bg: #120E1B;
  --bg-alt: #180F26;
  --surface: #1D1730;
  --surface-2: #241C3D;
  --surface-raised: #2A2147;

  --gold: #F2B705;
  --gold-dim: #B88C08;
  --violet: #7C5CFC;
  --violet-dim: #5B3FD9;
  --rose: #FF6F91;
  --teal: #4FD1C5;

  --text: #F5F1FF;
  --text-muted: #A79FC2;
  --text-faint: #6B6289;

  --border: rgba(247, 240, 255, 0.08);
  --border-strong: rgba(247, 240, 255, 0.16);

  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius-pill: 999px;

  --shadow-glow-gold: 0 0 24px rgba(242, 183, 5, 0.25);
  --shadow-glow-violet: 0 0 24px rgba(124, 92, 252, 0.3);
  --shadow-card: 0 8px 30px rgba(0, 0, 0, 0.35);

  --font-display: 'Big Shoulders Display', sans-serif;
  --font-body: 'Manrope', sans-serif;

  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: radial-gradient(ellipse 120% 80% at 50% -10%, #241a3d 0%, var(--bg) 55%);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
  height: 100%;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

h1, h2, h3, .display {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: 0.01em;
  line-height: 1.05;
  margin: 0;
}

p { margin: 0; line-height: 1.5; }

button {
  font-family: var(--font-body);
  border: none;
  cursor: pointer;
  background: none;
  color: inherit;
}

input, textarea, select {
  font-family: var(--font-body);
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 15px;
  width: 100%;
  transition: border-color 0.2s var(--ease-out), box-shadow 0.2s var(--ease-out);
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--violet);
  box-shadow: 0 0 0 3px rgba(124, 92, 252, 0.2);
}
input::placeholder, textarea::placeholder { color: var(--text-faint); }

/* ==========================================================================
   Хатти рӯшноии маркиз — Marquee light-strip decorative accent
   ========================================================================== */
.marquee-strip {
  height: 3px;
  background: repeating-linear-gradient(
    90deg, var(--gold) 0 8px, transparent 8px 16px
  );
  opacity: 0.5;
  animation: marquee-scroll 1.8s linear infinite;
}
@keyframes marquee-scroll {
  from { background-position: 0 0; }
  to { background-position: 32px 0; }
}

/* ==========================================================================
   Ҳолати боргирӣ / Loading & app shell
   ========================================================================== */
#app {
  flex: 1;
  display: flex;
  flex-direction: column;
  max-width: 480px;
  margin: 0 auto;
  width: 100%;
  min-height: 100vh;
  position: relative;
}

.screen {
  flex: 1;
  padding: 20px 18px 100px;
  overflow-y: auto;
  animation: screen-in 0.35s var(--ease-out);
}
@keyframes screen-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.page-title {
  font-size: 28px;
  color: var(--text);
  margin-bottom: 4px;
}
.page-subtitle {
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 20px;
}

/* ==========================================================================
   Онбординг — Onboarding carousel
   ========================================================================== */
.onboarding {
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse 120% 80% at 50% -10%, #2a1d47 0%, var(--bg) 60%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  max-width: 480px;
  margin: 0 auto;
}

.onb-slides {
  flex: 1;
  display: flex;
  overflow-x: hidden;
  position: relative;
}

.onb-slide {
  min-width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 32px;
  text-align: center;
  transition: transform 0.45s var(--ease-out), opacity 0.45s var(--ease-out);
}

.onb-icon {
  width: 120px;
  height: 120px;
  margin-bottom: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, var(--surface-raised), var(--surface));
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-glow-gold), inset 0 2px 8px rgba(255,255,255,0.05);
  transform-style: preserve-3d;
  animation: onb-icon-float 3.2s ease-in-out infinite;
}
@keyframes onb-icon-float {
  0%, 100% { transform: translateY(0) rotateY(0deg); }
  50% { transform: translateY(-8px) rotateY(6deg); }
}
.onb-icon svg { width: 56px; height: 56px; }

.onb-title {
  font-size: 26px;
  margin-bottom: 14px;
  color: var(--text);
}
.onb-text {
  font-size: 15px;
  color: var(--text-muted);
  max-width: 320px;
}

.onb-dots {
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 16px 0;
}
.onb-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border-strong);
  transition: all 0.3s var(--ease-spring);
}
.onb-dot.active {
  background: var(--gold);
  width: 24px;
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-glow-gold);
}

.onb-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 28px 36px;
  gap: 12px;
}
.onb-skip {
  color: var(--text-faint);
  font-size: 14px;
  padding: 10px;
}
.onb-next-btn {
  flex: 1;
  margin-left: 12px;
}

/* ==========================================================================
   Тугмаҳо — Buttons
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 22px;
  border-radius: var(--radius-md);
  font-weight: 700;
  font-size: 15px;
  transition: transform 0.15s var(--ease-spring), box-shadow 0.2s var(--ease-out), opacity 0.2s;
  transform-style: preserve-3d;
  width: 100%;
}
.btn:active { transform: scale(0.96) translateZ(-4px); }
.btn:disabled { opacity: 0.4; pointer-events: none; }

.btn-primary {
  background: linear-gradient(135deg, var(--gold) 0%, #D99A04 100%);
  color: #1A1206;
  box-shadow: var(--shadow-glow-gold), 0 4px 0 var(--gold-dim);
}
.btn-primary:active { box-shadow: 0 1px 0 var(--gold-dim); }

.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border-strong);
}

.btn-violet {
  background: linear-gradient(135deg, var(--violet) 0%, var(--violet-dim) 100%);
  color: white;
  box-shadow: var(--shadow-glow-violet), 0 4px 0 var(--violet-dim);
}
.btn-violet:active { box-shadow: 0 1px 0 var(--violet-dim); }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  width: auto;
  padding: 8px 12px;
}

.btn-danger {
  background: transparent;
  color: var(--rose);
  width: auto;
}

.btn-sm { padding: 9px 14px; font-size: 13px; width: auto; }

/* ==========================================================================
   Корт — Cards (rim-light spotlight, na uniform grey shadow)
   ========================================================================== */
.card {
  background: linear-gradient(160deg, var(--surface-raised) 0%, var(--surface) 60%);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  margin-bottom: 14px;
  position: relative;
  overflow: hidden;
  transition: transform 0.25s var(--ease-out), border-color 0.25s;
}
.card::before {
  content: '';
  position: absolute;
  top: -40%;
  right: -20%;
  width: 60%;
  height: 80%;
  background: radial-gradient(circle, rgba(242,183,5,0.08) 0%, transparent 70%);
  pointer-events: none;
}
.card:active { transform: scale(0.985); }
.card.tilt { will-change: transform; }

.card-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 6px;
}
.stat-card {
  background: var(--surface-2);
  border-radius: var(--radius-md);
  padding: 16px;
  border: 1px solid var(--border);
}
.stat-value {
  font-family: var(--font-display);
  font-size: 30px;
  color: var(--gold);
}
.stat-label {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ==========================================================================
   Варақаи поёнӣ — Bottom tab bar
   ========================================================================== */
.tabbar {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 10px 8px calc(10px + env(safe-area-inset-bottom));
  background: rgba(24, 17, 40, 0.88);
  backdrop-filter: blur(20px);
  border-top: 1px solid var(--border);
  z-index: 100;
}

.tab-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 6px 10px;
  color: var(--text-faint);
  font-size: 11px;
  font-weight: 600;
  transition: color 0.2s var(--ease-out), transform 0.2s var(--ease-spring);
  flex: 1;
}
.tab-item svg { width: 22px; height: 22px; transition: transform 0.2s var(--ease-spring); }
.tab-item.active { color: var(--gold); }
.tab-item.active svg { transform: translateY(-2px) scale(1.05); }
.tab-item:active { transform: scale(0.9); }

.tab-create {
  position: relative;
  top: -18px;
}
.tab-create-btn {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #FFD24D, var(--gold) 55%, var(--gold-dim) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 0 5px var(--bg), var(--shadow-glow-gold), 0 6px 0 var(--gold-dim);
  transition: transform 0.2s var(--ease-spring), box-shadow 0.2s;
  transform-style: preserve-3d;
}
.tab-create-btn svg { width: 26px; height: 26px; color: #1A1206; }
.tab-create-btn:active {
  transform: scale(0.9) translateY(3px);
  box-shadow: 0 0 0 5px var(--bg), 0 2px 0 var(--gold-dim);
}
.tab-create-ring {
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 2px solid rgba(242, 183, 5, 0.4);
  animation: pulse-ring 2.4s ease-out infinite;
}
@keyframes pulse-ring {
  0% { transform: scale(0.9); opacity: 0.8; }
  80% { transform: scale(1.35); opacity: 0; }
  100% { opacity: 0; }
}

/* ==========================================================================
   Пешнамоиши паём (Telegram bubble simulation)
   ========================================================================== */
.tg-preview-wrap {
  background: #0E1621;
  border-radius: var(--radius-lg);
  padding: 24px 16px;
  background-image: radial-gradient(circle at 20% 20%, rgba(255,255,255,0.02) 0, transparent 40%);
}
.tg-bubble {
  background: #1E2C3A;
  border-radius: 14px 14px 14px 4px;
  padding: 10px;
  max-width: 88%;
  color: #E8ECF1;
  font-size: 14.5px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
  animation: bubble-in 0.4s var(--ease-spring);
}
@keyframes bubble-in {
  from { opacity: 0; transform: translateY(10px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.tg-bubble img, .tg-bubble video {
  width: 100%;
  border-radius: 10px;
  margin-bottom: 8px;
  display: block;
}
.tg-bubble-text { padding: 4px 6px 2px; white-space: pre-wrap; }
.tg-bubble-buttons {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
}
.tg-bubble-button {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  padding: 9px;
  text-align: center;
  font-size: 13.5px;
  color: #6BB8FF;
}
.tg-bubble-protect-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--text-faint);
  margin-top: 10px;
}

/* ==========================================================================
   Форма — Form groups, toggles, segmented control
   ========================================================================== */
.field { margin-bottom: 16px; }
.field-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.field-help {
  font-size: 12px;
  color: var(--text-faint);
  margin-top: 5px;
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.toggle-row:last-child { border-bottom: none; }
.toggle-label { font-size: 14.5px; font-weight: 500; }

.switch {
  width: 46px;
  height: 26px;
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  position: relative;
  transition: background 0.25s var(--ease-out);
  flex-shrink: 0;
}
.switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--text-faint);
  transition: transform 0.25s var(--ease-spring), background 0.25s;
}
.switch.on { background: rgba(242,183,5,0.25); border-color: var(--gold-dim); }
.switch.on::after { transform: translateX(20px); background: var(--gold); }

.sub-options {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s var(--ease-out);
}
.sub-options.open { max-height: 200px; padding-top: 10px; }

/* ==========================================================================
   Тугмаи иловагӣ (chips) — Add button chips
   ========================================================================== */
.chip-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 13.5px;
}
.chip-remove { color: var(--rose); font-size: 18px; padding: 0 4px; }

/* ==========================================================================
   Media upload dropzone
   ========================================================================== */
.dropzone {
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius-md);
  padding: 24px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13.5px;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}
.dropzone:active { background: var(--surface-2); border-color: var(--gold-dim); }
.dropzone img, .dropzone video { max-width: 100%; border-radius: 10px; margin-top: 10px; }

/* ==========================================================================
   Статус-бейдж — Status badges
   ========================================================================== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.badge-gold { background: rgba(242,183,5,0.15); color: var(--gold); }
.badge-violet { background: rgba(124,92,252,0.15); color: var(--violet); }
.badge-teal { background: rgba(79,209,197,0.15); color: var(--teal); }
.badge-rose { background: rgba(255,111,145,0.15); color: var(--rose); }
.badge-muted { background: var(--surface-2); color: var(--text-muted); }

/* ==========================================================================
   Progress bar (расылка дар ҳоли фиристодан)
   ========================================================================== */
.progress-track {
  height: 6px;
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  overflow: hidden;
  margin: 10px 0;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--gold), var(--violet));
  border-radius: var(--radius-pill);
  transition: width 0.4s var(--ease-out);
}

/* ==========================================================================
   Модал — Modal / sheet
   ========================================================================== */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(8, 5, 15, 0.7);
  backdrop-filter: blur(4px);
  z-index: 150;
  display: flex;
  align-items: flex-end;
  animation: fade-in 0.2s var(--ease-out);
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.sheet {
  background: var(--surface);
  border-radius: 24px 24px 0 0;
  padding: 20px 20px calc(20px + env(safe-area-inset-bottom));
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  max-height: 85vh;
  overflow-y: auto;
  animation: sheet-up 0.32s var(--ease-out);
  border-top: 1px solid var(--border-strong);
}
@keyframes sheet-up { from { transform: translateY(100%); } to { transform: translateY(0); } }
.sheet-handle {
  width: 36px;
  height: 4px;
  background: var(--border-strong);
  border-radius: var(--radius-pill);
  margin: 0 auto 16px;
}

/* ==========================================================================
   Toast — эҳтироми паём
   ========================================================================== */
.toast {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  background: var(--surface-raised);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 12px 18px;
  font-size: 13.5px;
  font-weight: 600;
  box-shadow: var(--shadow-card);
  z-index: 300;
  opacity: 0;
  transition: all 0.3s var(--ease-spring);
  max-width: 90%;
  display: flex;
  align-items: center;
  gap: 8px;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.success { border-color: rgba(79,209,197,0.4); }
.toast.error { border-color: rgba(255,111,145,0.4); }

/* ==========================================================================
   Empty state
   ========================================================================== */
.empty-state {
  text-align: center;
  padding: 50px 20px;
  color: var(--text-faint);
}
.empty-state svg { width: 56px; height: 56px; margin-bottom: 14px; opacity: 0.5; }
.empty-state p { font-size: 14px; }

/* ==========================================================================
   Utility
   ========================================================================== */
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-8 { margin-bottom: 8px; }
.text-muted { color: var(--text-muted); }
.text-center { text-align: center; }
.spinner {
  width: 20px; height: 20px;
  border: 2.5px solid var(--border-strong);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin: 0 auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
