/* ============================================================
   ChatPortal — Global Stylesheet
   Dark purple theme, mobile-first
   ============================================================ */

/* ── Reset & Base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg-deep:       #0e0817;
  --bg-dark:       #150d24;
  --bg-card:       #1e1333;
  --bg-card2:      #251740;
  --bg-input:      #1a1030;
  --border:        #2e1f50;
  --accent-pink:   #e91e8c;
  --accent-purple: #9c27b0;
  --accent-gold:   #f5c518;
  --accent-green:  #4caf50;
  --text-primary:  #f0eaf8;
  --text-secondary:#a89bc2;
  --text-muted:    #6b5a85;
  --bubble-ai:     #1e1333;
  --bubble-user:   #6a1fa8;
  --radius:        14px;
  --radius-sm:     8px;
  --nav-height:    60px;
  --header-height: 58px;
}

html, body {
  background: var(--bg-deep);
  color: var(--text-primary);
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent-pink); text-decoration: none; }
a:hover { text-decoration: underline; }

img { max-width: 100%; display: block; }

/* ── Scrollbar ──────────────────────────────────────────── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: var(--bg-dark); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* ── Utility ────────────────────────────────────────────── */
.hidden   { display: none !important; }
.sr-only  { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }
.text-center { text-align: center; }
.text-muted  { color: var(--text-muted); }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 16px; }
.mb-3 { margin-bottom: 16px; }

/* ── Buttons ────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 11px 24px;
  border-radius: 50px;
  border: none;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity .2s, transform .1s;
  white-space: nowrap;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary   { background: linear-gradient(135deg, var(--accent-pink), var(--accent-purple)); color: #fff; }
.btn-gold      { background: linear-gradient(135deg, #f5c518, #e5a800); color: #1a1000; }
.btn-outline   { background: transparent; border: 1.5px solid var(--accent-pink); color: var(--accent-pink); }
.btn-ghost     { background: rgba(255,255,255,.05); color: var(--text-primary); }
.btn-danger    { background: #c62828; color: #fff; }
.btn-block     { width: 100%; }
.btn-sm        { padding: 7px 16px; font-size: 13px; }
.btn-lg        { padding: 14px 32px; font-size: 17px; }

/* ── Top header ─────────────────────────────────────────── */
.top-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-height);
  background: var(--bg-dark);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  gap: 10px;
}
.top-header .logo {
  font-size: 20px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent-pink), var(--accent-gold));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.top-header .header-actions { display: flex; gap: 8px; align-items: center; }

/* ── Bottom nav ─────────────────────────────────────────── */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 100;
  height: var(--nav-height);
  background: var(--bg-dark);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
}
.bottom-nav .nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 6px 0;
  cursor: pointer;
  text-decoration: none;
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 500;
  transition: color .2s;
  position: relative;
}
.bottom-nav .nav-item.active { color: var(--accent-pink); }
.bottom-nav .nav-item svg,
.bottom-nav .nav-item .nav-icon { width: 22px; height: 22px; }
.bottom-nav .nav-badge {
  position: absolute;
  top: 4px;
  right: calc(50% - 18px);
  background: var(--accent-pink);
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
}
.bottom-nav .nav-badge.gold { background: var(--accent-gold); color: #1a1000; }

/* Page body padded for bottom nav */
.page-body {
  padding-bottom: calc(var(--nav-height) + 16px);
  min-height: 100dvh;
}

/* ── Alert / Flash ──────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
  font-size: 14px;
}
.alert-error   { background: rgba(198,40,40,.2); border: 1px solid #c62828; color: #ff8a80; }
.alert-success { background: rgba(76,175,80,.15); border: 1px solid #4caf50; color: #a5d6a7; }
.alert-info    { background: rgba(156,39,176,.2); border: 1px solid var(--accent-purple); color: #ce93d8; }

/* ── Card ───────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
}

/* ── Form ───────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 500;
}
.form-control {
  width: 100%;
  padding: 12px 14px;
  background: var(--bg-input);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 15px;
  outline: none;
  transition: border-color .2s;
}
.form-control:focus { border-color: var(--accent-purple); }
.form-control::placeholder { color: var(--text-muted); }
textarea.form-control { resize: vertical; min-height: 90px; }

/* ── Profile Grid (Homepage) ────────────────────────────── */
.profile-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  padding: 10px;
}

.profile-card {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  aspect-ratio: 3/4;
  background: var(--bg-card2);
  cursor: pointer;
  transition: transform .2s;
}
.profile-card:active { transform: scale(.97); }

.profile-card__thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.profile-card__thumb-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--bg-card2), #3a2060);
  font-size: 60px;
}

.profile-card__overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,.75) 0%, transparent 50%);
}

.profile-card__info {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  padding: 10px;
}

.profile-card__name {
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 4px;
}

.profile-card__meta {
  font-size: 11px;
  color: rgba(255,255,255,.75);
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 2px;
}

.badge-online {
  background: var(--accent-green);
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 20px;
  display: inline-flex;
  align-items: center;
  gap: 3px;
}
.badge-online::before {
  content: '';
  width: 5px; height: 5px;
  background: #fff;
  border-radius: 50%;
  display: inline-block;
}

.badge-premium {
  position: absolute;
  top: 8px; right: 8px;
  background: linear-gradient(135deg, var(--accent-gold), #e5a800);
  color: #1a1000;
  font-size: 10px;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 20px;
}

.profile-card__play {
  position: absolute;
  bottom: 40px; right: 10px;
  width: 38px; height: 38px;
  background: linear-gradient(135deg, var(--accent-gold), #e5a800);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 12px rgba(245,197,24,.4);
}

/* ── Chat page ───────────────────────────────────────────── */
.chat-page { display: flex; flex-direction: column; height: 100dvh; }

.chat-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--bg-dark);
  border-bottom: 1px solid var(--border);
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: var(--header-height);
}

.chat-header__back {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
}

.chat-header__avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--accent-pink);
  flex-shrink: 0;
}
.chat-header__avatar-placeholder {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-purple), var(--accent-pink));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.chat-header__info { flex: 1; min-width: 0; }
.chat-header__name {
  font-size: 16px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-header__status {
  font-size: 11px;
  color: var(--accent-green);
  display: flex;
  align-items: center;
  gap: 4px;
}
.chat-header__status.offline { color: var(--text-muted); }

/* Chat messages area */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.chat-date-divider {
  text-align: center;
  font-size: 11px;
  color: var(--text-muted);
  margin: 10px 0;
}

.bubble-row { display: flex; align-items: flex-end; gap: 6px; }
.bubble-row.user  { flex-direction: row-reverse; }
.bubble-row.ai    { flex-direction: row; }

.bubble-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  align-self: flex-end;
}
.bubble-avatar-placeholder {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-purple), var(--accent-pink));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  flex-shrink: 0;
}

.bubble {
  max-width: 74%;
  padding: 9px 13px;
  border-radius: 18px;
  font-size: 14.5px;
  line-height: 1.45;
  position: relative;
  word-break: break-word;
}
.bubble.ai   {
  background: var(--bubble-ai);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
  color: var(--text-primary);
}
.bubble.user {
  background: var(--bubble-user);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.bubble.system {
  background: rgba(156,39,176,.1);
  border: 1px dashed var(--accent-purple);
  color: var(--text-secondary);
  font-size: 12px;
  border-radius: var(--radius-sm);
  text-align: center;
  align-self: center;
  max-width: 90%;
}
.bubble__time {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 3px;
  text-align: right;
}

/* Stagger animation for intro messages */
.bubble-row { animation: bubbleFadeIn .3s ease both; }
@keyframes bubbleFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Chat bottom bar ─────────────────────────────────────── */
.chat-bottom {
  border-top: 1px solid var(--border);
  background: var(--bg-dark);
}

.chat-unlock-banner {
  background: linear-gradient(135deg, #1a0a2e, #2e1050);
  border-bottom: 1px solid var(--border);
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.chat-unlock-banner__text {
  font-size: 12px;
  color: var(--text-secondary);
  flex: 1;
}
.chat-unlock-banner__text strong { color: var(--text-primary); }

.chat-composer {
  padding: 8px 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.chat-composer__input {
  flex: 1;
  background: var(--bg-input);
  border: 1.5px solid var(--border);
  border-radius: 24px;
  padding: 10px 14px;
  color: var(--text-primary);
  font-size: 14px;
  outline: none;
}
.chat-composer__input:disabled {
  opacity: .5;
  cursor: not-allowed;
}
.chat-composer__input::placeholder { color: var(--text-muted); }
.chat-composer__btn {
  width: 40px; height: 40px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity .2s;
  flex-shrink: 0;
}
.chat-composer__btn.send   { background: linear-gradient(135deg, var(--accent-pink), var(--accent-purple)); color: #fff; }
.chat-composer__btn:disabled { opacity: .4; cursor: not-allowed; }

/* ── Preview page ───────────────────────────────────────── */
.preview-page {
  position: fixed;
  inset: 0;
  background: #000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.preview-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  position: absolute;
  inset: 0;
}
.preview-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,.6) 0%, transparent 40%);
}
.preview-countdown {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 72px; height: 72px;
  border-radius: 50%;
  background: rgba(0,0,0,.55);
  border: 3px solid var(--accent-gold);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  font-weight: 900;
  color: var(--accent-gold);
  pointer-events: none;
}
.preview-profile-info {
  position: absolute;
  bottom: 30px;
  left: 0; right: 0;
  text-align: center;
  color: #fff;
}
.preview-profile-info h2 { font-size: 22px; font-weight: 800; }
.preview-profile-info p  { font-size: 13px; color: rgba(255,255,255,.75); margin-top: 4px; }

/* ── Auth pages ─────────────────────────────────────────── */
.auth-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: 24px 16px;
}
.auth-box {
  width: 100%;
  max-width: 400px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 24px;
}
.auth-logo {
  text-align: center;
  font-size: 26px;
  font-weight: 900;
  background: linear-gradient(135deg, var(--accent-pink), var(--accent-gold));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 6px;
}
.auth-subtitle {
  text-align: center;
  color: var(--text-secondary);
  font-size: 13px;
  margin-bottom: 24px;
}
.auth-footer {
  text-align: center;
  margin-top: 16px;
  font-size: 13px;
  color: var(--text-secondary);
}

/* ── Membership / VIP page ───────────────────────────────── */
.vip-header {
  background: linear-gradient(135deg, #1a0a2e 0%, #3a0a6e 100%);
  padding: 32px 20px;
  text-align: center;
  border-bottom: 1px solid var(--border);
}
.vip-crown { font-size: 52px; margin-bottom: 8px; }
.vip-title {
  font-size: 24px;
  font-weight: 900;
  background: linear-gradient(135deg, var(--accent-gold), #fff59d);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.vip-subtitle { color: var(--text-secondary); font-size: 13px; margin-top: 6px; }

.plan-card {
  background: var(--bg-card2);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
  margin: 16px;
  position: relative;
  transition: border-color .2s;
}
.plan-card.active-plan { border-color: var(--accent-gold); }
.plan-card__price {
  font-size: 36px;
  font-weight: 900;
  color: var(--accent-gold);
}
.plan-card__period { color: var(--text-secondary); font-size: 13px; }
.plan-card__features { margin: 14px 0; text-align: left; }
.plan-card__feature {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  padding: 4px 0;
  color: var(--text-secondary);
}
.plan-card__feature::before {
  content: '✓';
  color: var(--accent-green);
  font-weight: 700;
}

.billing-disclosure {
  margin: 0 16px 16px;
  padding: 12px 14px;
  background: rgba(255,255,255,.04);
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.6;
}

/* ── Admin panel ────────────────────────────────────────── */
.admin-layout { display: flex; min-height: 100vh; }
.admin-sidebar {
  width: 230px;
  background: var(--bg-dark);
  border-right: 1px solid var(--border);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  bottom: 0;
  z-index: 200;
  overflow-y: auto;
}
.admin-sidebar__logo {
  padding: 18px 16px;
  font-size: 18px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent-pink), var(--accent-gold));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  border-bottom: 1px solid var(--border);
}
.admin-sidebar__nav { padding: 8px 0; flex: 1; }
.admin-sidebar__link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  color: var(--text-secondary);
  font-size: 14px;
  text-decoration: none;
  transition: background .15s, color .15s;
  border-radius: 0;
}
.admin-sidebar__link:hover,
.admin-sidebar__link.active {
  background: rgba(233,30,140,.1);
  color: var(--accent-pink);
  text-decoration: none;
}
.admin-sidebar__section {
  padding: 14px 16px 4px;
  font-size: 10px;
  letter-spacing: .8px;
  text-transform: uppercase;
  color: var(--text-muted);
}

.admin-main {
  margin-left: 230px;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
.admin-topbar {
  height: 54px;
  background: var(--bg-dark);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 100;
}
.admin-topbar__title { font-size: 17px; font-weight: 700; }
.admin-content { padding: 20px; flex: 1; }

/* Admin stat cards */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.stat-card__label {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.stat-card__value {
  font-size: 26px;
  font-weight: 800;
  color: var(--accent-pink);
}
.stat-card__sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Admin table */
.admin-table-wrap { overflow-x: auto; }
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.admin-table th {
  text-align: left;
  padding: 10px 12px;
  background: var(--bg-card2);
  color: var(--text-secondary);
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.admin-table td {
  padding: 10px 12px;
  border-bottom: 1px solid rgba(46,31,80,.5);
  vertical-align: middle;
}
.admin-table tr:last-child td { border-bottom: none; }
.admin-table tr:hover td { background: rgba(255,255,255,.02); }

.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}
.badge-success  { background: rgba(76,175,80,.2);  color: #a5d6a7; }
.badge-warning  { background: rgba(255,193,7,.2);  color: #ffe082; }
.badge-danger   { background: rgba(198,40,40,.2);  color: #ff8a80; }
.badge-info     { background: rgba(156,39,176,.2); color: #ce93d8; }
.badge-muted    { background: rgba(255,255,255,.06); color: var(--text-muted); }

/* ── Modal ───────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.7);
  z-index: 500;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.modal-backdrop.center { align-items: center; }
.modal-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 20px 16px 28px;
  width: 100%;
  max-width: 480px;
  max-height: 90dvh;
  overflow-y: auto;
  animation: slideUp .25s ease;
}
.modal-backdrop.center .modal-box {
  border-radius: var(--radius);
}
@keyframes slideUp {
  from { transform: translateY(60px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}
.modal-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 14px;
}

/* ── Tabs ────────────────────────────────────────────────── */
.tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}
.tab-btn {
  padding: 10px 18px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: color .2s, border-color .2s;
}
.tab-btn.active {
  color: var(--accent-pink);
  border-bottom-color: var(--accent-pink);
}

/* ── Responsive: desktop sidebar collapse hint ───────────── */
@media (max-width: 640px) {
  .admin-sidebar { width: 200px; }
  .admin-main    { margin-left: 200px; }
}
@media (max-width: 480px) {
  .admin-sidebar { transform: translateX(-100%); transition: transform .3s; }
  .admin-sidebar.open { transform: translateX(0); }
  .admin-main    { margin-left: 0; }
}
