/* ============================================================
   CMS Platform — Dashboard & Auth Styles
   ============================================================ */

:root {
  --primary: #4f46e5;
  --primary-dark: #3730a3;
  --danger:  #dc2626;
  --success: #16a34a;
  --warning: #d97706;
  --bg:      #f1f5f9;
  --surface: #ffffff;
  --border:  #e2e8f0;
  --text:    #0f172a;
  --muted:   #64748b;
  --sidebar-w: 240px;
  --radius: 8px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-size: 15px;
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .55rem 1.2rem; border-radius: var(--radius);
  font-size: .9rem; font-weight: 600; cursor: pointer;
  border: 1.5px solid transparent; transition: background .15s, opacity .15s;
  line-height: 1;
}
.btn:hover { opacity: .88; text-decoration: none; }
.btn-primary  { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-outline  { background: transparent; color: var(--primary); border-color: var(--primary); }
.btn-danger   { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-ghost-sm { background: rgba(255,255,255,.15); color: #fff; border: none; padding: .35rem .85rem; border-radius: 6px; font-size: .8rem; cursor: pointer; }
.btn-sm       { padding: .35rem .85rem; font-size: .82rem; }
.btn-lg       { padding: .8rem 2rem; font-size: 1rem; }
.btn-block    { width: 100%; justify-content: center; }

/* ── Alerts ──────────────────────────────────────────────── */
.alert { padding: .85rem 1.2rem; border-radius: var(--radius); margin-bottom: 1.25rem; font-size: .9rem; }
.alert-success { background: #dcfce7; color: #14532d; border: 1px solid #bbf7d0; }
.alert-error   { background: #fee2e2; color: #7f1d1d; border: 1px solid #fecaca; }

/* ── Badges ──────────────────────────────────────────────── */
.badge { display: inline-block; padding: .2rem .65rem; border-radius: 999px; font-size: .75rem; font-weight: 600; line-height: 1; }
.badge-green  { background: #dcfce7; color: #15803d; }
.badge-red    { background: #fee2e2; color: #b91c1c; }
.badge-yellow { background: #fef9c3; color: #a16207; }
.badge-gray   { background: #f1f5f9; color: #475569; }
.badge-blue   { background: #dbeafe; color: #1d4ed8; }
.badge-purple { background: #ede9fe; color: #6d28d9; }

/* ── Auth Layout ─────────────────────────────────────────── */
.auth-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: var(--bg); }
.auth-wrapper { width: 100%; max-width: 420px; padding: 1rem; }
.auth-brand { text-align: center; margin-bottom: 2rem; font-size: 1.4rem; font-weight: 800; color: var(--primary); }
.auth-brand a { color: inherit; text-decoration: none; }
.auth-card { background: var(--surface); border-radius: 12px; padding: 2.5rem; box-shadow: 0 4px 24px rgba(0,0,0,.08); }
.auth-title { font-size: 1.6rem; font-weight: 800; margin-bottom: .25rem; }
.auth-sub { color: var(--muted); margin-bottom: 2rem; }
.auth-footer { margin-top: 1.5rem; text-align: center; font-size: .88rem; color: var(--muted); }

/* ── Forms ───────────────────────────────────────────────── */
.form-group { margin-bottom: 1.1rem; }
.form-group label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: .4rem; color: var(--text); }
.form-group input[type=text],
.form-group input[type=email],
.form-group input[type=password],
.form-group input[type=url],
.form-group input[type=color],
.form-group select,
.form-group textarea {
  width: 100%; padding: .6rem .9rem; border: 1.5px solid var(--border);
  border-radius: var(--radius); font-size: .95rem; background: var(--surface);
  color: var(--text); transition: border-color .15s;
  font-family: inherit;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,70,229,.15); }
.form-group textarea { resize: vertical; min-height: 80px; }
.form-error { color: var(--danger); font-size: .82rem; margin-top: .35rem; }
.form-hint  { color: var(--muted); font-size: .8rem; margin-top: .3rem; display: block; }
.form-row   { display: flex; align-items: center; justify-content: space-between; }
.form-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-actions { margin-top: 1.5rem; display: flex; gap: .75rem; flex-wrap: wrap; }
.form-divider { border: none; border-top: 1px solid var(--border); margin: 2rem 0; }
.form-card { background: var(--surface); border-radius: var(--radius); border: 1px solid var(--border); padding: 2rem; }
.auth-form .btn { margin-top: .5rem; }
.checkbox-label { display: flex; align-items: center; gap: .5rem; font-size: .88rem; cursor: pointer; }
.link-sm { font-size: .88rem; }
.input-prefix-wrap { display: flex; align-items: stretch; border: 1.5px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.input-prefix { background: var(--bg); padding: .6rem .75rem; color: var(--muted); font-size: .95rem; border-right: 1.5px solid var(--border); }
.input-prefix-wrap input { border: none; border-radius: 0; flex: 1; }
.input-prefix-wrap input:focus { box-shadow: none; }
.section-title { font-size: 1.1rem; font-weight: 700; margin-bottom: 1rem; color: var(--text); }

/* ── Dashboard Layout ────────────────────────────────────── */
.impersonate-banner { background: var(--warning); color: #fff; text-align: center; padding: .6rem 1rem; font-size: .875rem; display: flex; align-items: center; justify-content: center; gap: 1rem; }
.layout { display: flex; min-height: 100vh; }

.sidebar { width: var(--sidebar-w); background: #1e1b4b; color: #c7d2fe; display: flex; flex-direction: column; flex-shrink: 0; position: fixed; top: 0; left: 0; height: 100%; overflow-y: auto; }
.impersonate-banner ~ .layout .sidebar { top: 38px; height: calc(100% - 38px); }
.sidebar-brand { padding: 1.5rem 1.25rem 1rem; font-size: 1.15rem; font-weight: 800; color: #fff; letter-spacing: -.01em; }
.sidebar-brand a { color: #fff; text-decoration: none; }
.sidebar-nav { list-style: none; flex: 1; padding: .5rem 0; }
.sidebar-nav li { margin: 0; }
.nav-link { display: block; padding: .55rem 1.25rem; color: #a5b4fc; font-size: .9rem; font-weight: 500; border-radius: 0; transition: background .12s, color .12s; }
.nav-link:hover, .nav-link.active { background: rgba(255,255,255,.1); color: #fff; text-decoration: none; }
.nav-admin { color: #fbbf24 !important; }
.nav-divider { height: 1px; background: rgba(255,255,255,.08); margin: .5rem 1rem; }
.sidebar-footer { padding: 1rem 1.25rem; border-top: 1px solid rgba(255,255,255,.1); }
.sidebar-user { display: block; font-size: .85rem; color: #a5b4fc; margin-bottom: .4rem; font-weight: 600; }
.nav-link-sm { font-size: .8rem; color: #818cf8; }

.main-content { margin-left: var(--sidebar-w); flex: 1; padding: 2.5rem 2rem; max-width: 1200px; width: 100%; }

/* ── Page Header ─────────────────────────────────────────── */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 2rem; flex-wrap: wrap; gap: 1rem; }
.page-header h1 { font-size: 1.7rem; font-weight: 800; }
.text-muted { color: var(--muted); font-size: .9rem; }

/* ── Stats ───────────────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 1rem; margin-bottom: 2rem; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.5rem; text-decoration: none; color: var(--text); transition: box-shadow .15s; display: block; }
.stat-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,.08); }
.stat-number { font-size: 2.5rem; font-weight: 800; color: var(--primary); line-height: 1; }
.stat-label  { color: var(--muted); font-size: .85rem; margin-top: .4rem; }

/* ── Cards ───────────────────────────────────────────────── */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1.25rem; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); display: flex; flex-direction: column; }
.card-body { padding: 1.25rem; flex: 1; }
.card-title { font-size: 1.05rem; font-weight: 700; margin-bottom: .3rem; }
.card-meta  { color: var(--muted); font-size: .85rem; }
.card-footer { padding: .75rem 1.25rem; border-top: 1px solid var(--border); display: flex; gap: .5rem; flex-wrap: wrap; }

/* ── Tables ──────────────────────────────────────────────── */
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th { background: var(--bg); padding: .75rem 1rem; text-align: left; font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); border-bottom: 1px solid var(--border); }
.table td { padding: .85rem 1rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: #fafafa; }
.actions-cell { display: flex; gap: .4rem; flex-wrap: wrap; align-items: center; }
.inline-form { display: inline; }

/* ── Empty State ─────────────────────────────────────────── */
.empty-state { text-align: center; padding: 4rem 2rem; color: var(--muted); }
.empty-state p { margin-bottom: 1.5rem; }

/* ── Info Box ────────────────────────────────────────────── */
.info-box { background: #eff6ff; border: 1px solid #bfdbfe; border-radius: var(--radius); padding: 1rem 1.25rem; font-size: .9rem; color: #1e40af; margin-bottom: 1.5rem; }
.ip-code { font-family: monospace; background: #dbeafe; padding: .1rem .5rem; border-radius: 4px; font-weight: 700; }

/* ── Template Grid ───────────────────────────────────────── */
.template-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 1rem; margin-top: .5rem; }
.template-card { border: 2px solid var(--border); border-radius: var(--radius); padding: 1rem; cursor: pointer; transition: border-color .15s; }
.template-card input[type=radio] { display: none; }
.template-card.selected, .template-card:hover { border-color: var(--primary); }
.template-thumb { height: 100px; background: var(--bg); border-radius: 4px; overflow: hidden; margin-bottom: .75rem; display: flex; align-items: center; justify-content: center; }
.template-thumb img { width: 100%; height: 100%; object-fit: cover; }
.template-thumb-placeholder { font-size: 2.5rem; font-weight: 800; color: var(--primary); }
.template-info strong { display: block; font-size: .95rem; }
.template-info p { font-size: .82rem; color: var(--muted); margin-top: .2rem; }

/* ── Plans ───────────────────────────────────────────────── */
.plan-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1.5rem; margin-bottom: 2rem; }
.plan-card { background: var(--surface); border: 2px solid var(--border); border-radius: 12px; padding: 2rem; position: relative; }
.plan-featured { border-color: var(--primary); }
.plan-current { opacity: .7; }
.plan-badge { position: absolute; top: -12px; left: 50%; transform: translateX(-50%); background: var(--primary); color: #fff; font-size: .75rem; font-weight: 700; padding: .2rem .85rem; border-radius: 999px; }
.plan-name { font-size: 1.5rem; font-weight: 800; margin-bottom: 1.25rem; }
.plan-features ul { list-style: none; padding: 0; margin-bottom: 2rem; }
.plan-features li { padding: .4rem 0; font-size: .9rem; border-bottom: 1px solid var(--border); }
.plan-features li::before { content: "✓ "; color: var(--success); font-weight: 700; }

/* ── Media Grid ──────────────────────────────────────────── */
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 1rem; }
.media-item { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.media-item img { width: 100%; height: 120px; object-fit: cover; display: block; }
.media-file-icon { height: 120px; display: flex; align-items: center; justify-content: center; font-size: 3rem; background: var(--bg); }
.media-info { padding: .6rem .75rem; font-size: .8rem; }
.media-name { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--muted); margin-bottom: .4rem; }
.btn-copy { background: transparent; border: 1px solid var(--border); border-radius: 4px; padding: .2rem .6rem; font-size: .78rem; cursor: pointer; color: var(--muted); }

/* ── Misc ────────────────────────────────────────────────── */
.quick-actions h2 { font-size: 1.1rem; margin-bottom: 1rem; }
.actions-row { display: flex; gap: .75rem; flex-wrap: wrap; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 2rem; }
.mt-4 { margin-top: 2rem; }
.mb-4 { margin-bottom: 2rem; }
code { font-family: 'Courier New', monospace; background: var(--bg); padding: .1rem .4rem; border-radius: 4px; font-size: .88em; }
.code-block { background: #1e293b; color: #e2e8f0; padding: 1rem; border-radius: 6px; font-family: monospace; font-size: .85rem; overflow-x: auto; margin-top: .75rem; white-space: pre; }
.img-preview { max-width: 200px; margin-top: .5rem; border-radius: 6px; border: 1px solid var(--border); }

/* ── Sidebar Enhancements ────────────────────────────────── */
.nav-section-label { display: block; padding: .5rem 1.25rem .2rem; font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: #6366f1; }

/* ── Card Header ─────────────────────────────────────────── */
.card-header { padding: 1rem 1.25rem; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }

/* ── Two-col grid ────────────────────────────────────────── */
.two-col { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }

/* ── Section Header ──────────────────────────────────────── */
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.section-header h2 { font-size: 1.2rem; font-weight: 700; }

/* ── Page Subtitle / Back link ───────────────────────────── */
.page-subtitle { color: var(--muted); font-size: .9rem; }
.back-link { font-size: .85rem; color: var(--muted); display: block; margin-bottom: .5rem; }
.back-link:hover { color: var(--primary); }

/* ── Extra badges ────────────────────────────────────────── */
.badge-success { background: #dcfce7; color: #15803d; }
.badge-neutral { background: #f1f5f9; color: #475569; }
.badge-warning { background: #fef9c3; color: #a16207; }

/* ── Extra button variants ───────────────────────────────── */
.btn-secondary { background: var(--bg); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: #e2e8f0; }

/* ── Typography helpers ──────────────────────────────────── */
.text-sm   { font-size: .875rem; }
.text-right { text-align: right; }
.req { color: var(--danger); }

/* ── Form helpers ────────────────────────────────────────── */
.form-label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: .4rem; color: var(--text); }
.form-input { width: 100%; padding: .6rem .9rem; border: 1.5px solid var(--border); border-radius: var(--radius); font-size: .95rem; background: var(--surface); color: var(--text); font-family: inherit; transition: border-color .15s; }
.form-input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,70,229,.15); }
.form-mono { font-family: 'Courier New', monospace; font-size: .82rem; }
.form-check { display: flex; align-items: center; gap: .5rem; font-size: .9rem; cursor: pointer; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

/* ── Tab Bar ─────────────────────────────────────────────── */
.tab-bar { display: flex; gap: .25rem; border-bottom: 2px solid var(--border); }
.tab-link { padding: .55rem 1rem; font-size: .88rem; font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -2px; transition: color .15s, border-color .15s; }
.tab-link:hover { color: var(--primary); text-decoration: none; }
.tab-link.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ── Toast ───────────────────────────────────────────────── */
.toast { position: fixed; bottom: 1.5rem; right: 1.5rem; background: #1e293b; color: #fff; padding: .65rem 1.25rem; border-radius: var(--radius); font-size: .875rem; box-shadow: 0 4px 16px rgba(0,0,0,.2); z-index: 9999; }

/* ── AV Media Cards ──────────────────────────────────────── */
.media-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; }
.media-thumb { position: relative; height: 140px; background: #0f172a; display: flex; align-items: center; justify-content: center; }
.media-thumb-audio { background: linear-gradient(135deg, #1e1b4b, #312e81); }
.media-thumb-video { background: #0f172a; }
.media-thumb img { width: 100%; height: 100%; object-fit: cover; }
.media-icon { font-size: 3rem; }
.media-type-badge { position: absolute; top: .5rem; right: .5rem; background: rgba(0,0,0,.6); color: #fff; font-size: .7rem; font-weight: 700; padding: .15rem .55rem; border-radius: 999px; text-transform: uppercase; }
.media-info { padding: .85rem; flex: 1; display: flex; flex-direction: column; gap: .35rem; }
.media-title { font-size: .9rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.media-meta { font-size: .78rem; color: var(--muted); }
.media-actions { display: flex; gap: .4rem; flex-wrap: wrap; margin-top: auto; padding-top: .5rem; }

/* ── Fourthwall Product Preview ──────────────────────────── */
.product-preview-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 1rem; }
.product-preview-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; text-align: center; padding-bottom: .75rem; }
.product-preview-img { width: 100%; height: 120px; object-fit: cover; display: block; background: var(--bg); }
.product-preview-img-ph { width: 100%; height: 120px; background: var(--bg); display: flex; align-items: center; justify-content: center; font-size: 2.5rem; }
.product-preview-name { font-size: .82rem; font-weight: 600; padding: .5rem .5rem .2rem; }
.product-preview-price { font-size: .8rem; color: var(--primary); font-weight: 700; }
.product-preview-more { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); display: flex; align-items: center; justify-content: center; height: 175px; color: var(--muted); font-size: .9rem; font-weight: 600; }

/* ── Home Page ───────────────────────────────────────────── */
.home-body { background: #fff; }
.home-header { border-bottom: 1px solid var(--border); padding: 1rem 0; }
.home-header .container { display: flex; justify-content: space-between; align-items: center; }
.home-logo { font-size: 1.3rem; font-weight: 800; color: var(--primary); }
.home-hero { padding: 7rem 0; text-align: center; background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%); color: #fff; }
.home-hero h1 { font-size: clamp(2rem, 5vw, 3.5rem); font-weight: 900; line-height: 1.15; margin-bottom: 1rem; }
.home-hero p { font-size: 1.15rem; opacity: .9; max-width: 560px; margin: 0 auto 2.5rem; }
.hero-actions { display: flex; gap: 1rem; justify-content: center; flex-wrap: wrap; }
.home-features { padding: 5rem 0; }
.home-features .container { max-width: 1100px; margin: 0 auto; padding: 0 1.5rem; }
.feature-card { text-align: center; padding: 2rem; }
.feature-icon { font-size: 2.5rem; margin-bottom: 1rem; }
.feature-card h3 { font-size: 1.2rem; margin-bottom: .75rem; }
.feature-card p { color: var(--muted); }
