/* ═══════════════════════════════════════════
   SiteBuilder — Design System
   Inspired by lidorub.online + geo-crm admin
   ═══════════════════════════════════════════ */

:root {
  --bg:        #070c18;
  --bg2:       #0d1526;
  --card:      #0f1829;
  --card2:     #141f33;
  --border:    rgba(255,255,255,0.07);
  --border2:   rgba(255,255,255,0.12);
  --text:      #f1f5f9;
  --muted:     #94a3b8;
  --muted2:    #64748b;
  --accent:    #6366f1;
  --accent2:   #818cf8;
  --cyan:      #06b6d4;
  --green:     #22c55e;
  --red:       #ef4444;
  --yellow:    #f59e0b;
  --radius:    12px;
  --radius-lg: 20px;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', sans-serif;
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ── Typography ── */
h1 { font-size: clamp(2rem, 5vw, 3.5rem); font-weight: 800; line-height: 1.15; }
h2 { font-size: clamp(1.5rem, 3vw, 2.25rem); font-weight: 700; }
h3 { font-size: 1.2rem; font-weight: 600; }
.muted  { color: var(--muted); }
.accent { color: var(--accent2); }
.cyan   { color: var(--cyan); }
.green  { color: var(--green); }

/* ── Layout ── */
.container { max-width: 1200px; margin: 0 auto; padding: 0 24px; }
.section    { padding: 80px 0; }
.section-sm { padding: 48px 0; }

/* ── Cards ── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  transition: border-color .2s, transform .2s;
}
.card:hover { border-color: var(--border2); }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 12px 28px; border-radius: 50px;
  font-weight: 600; font-size: 15px; cursor: pointer;
  border: none; text-decoration: none; transition: all .2s;
  white-space: nowrap;
}
.btn-primary {
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff; box-shadow: 0 4px 24px rgba(99,102,241,.35);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 32px rgba(99,102,241,.5); }
.btn-outline {
  background: transparent; color: var(--muted);
  border: 1px solid var(--border2);
}
.btn-outline:hover { color: var(--text); border-color: rgba(255,255,255,.25); background: rgba(255,255,255,.05); }
.btn-sm { padding: 8px 18px; font-size: 13px; }
.btn-danger { background: rgba(239,68,68,.15); color: var(--red); border: 1px solid rgba(239,68,68,.25); }
.btn-success { background: rgba(34,197,94,.15); color: var(--green); border: 1px solid rgba(34,197,94,.25); }
.btn-warning { background: rgba(234,179,8,.15); color: #f59e0b; border: 1px solid rgba(234,179,8,.35); }

/* ── Form ── */
.form-group { margin-bottom: 20px; }
.form-label { display: block; color: var(--muted); font-size: 13px; margin-bottom: 6px; font-weight: 500; }
.form-input, .form-select, .form-textarea {
  width: 100%; background: var(--bg2); border: 1px solid var(--border2);
  color: var(--text); padding: 10px 14px; border-radius: var(--radius);
  font-size: 14px; transition: border-color .2s; outline: none;
  font-family: inherit;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(99,102,241,.15);
}
.form-textarea { resize: vertical; min-height: 80px; }

/* ── Badge ── */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 12px; border-radius: 50px; font-size: 12px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .5px;
}
.badge-green { background: rgba(34,197,94,.12); color: var(--green); border: 1px solid rgba(34,197,94,.2); }
.badge-accent { background: rgba(99,102,241,.15); color: var(--accent2); border: 1px solid rgba(99,102,241,.25); }
.badge-cyan { background: rgba(6,182,212,.12); color: var(--cyan); border: 1px solid rgba(6,182,212,.2); }

/* ── Glow dot ── */
.dot-pulse { width: 7px; height: 7px; border-radius: 50%; background: var(--green); animation: pulse 2s infinite; }
@keyframes pulse { 0%,100%{opacity:1;transform:scale(1)} 50%{opacity:.5;transform:scale(1.3)} }

/* ── Admin Sidebar ── */
.admin-layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 240px; background: var(--bg2); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; flex-shrink: 0; position: fixed;
  top: 0; left: 0; height: 100vh; overflow-y: auto; z-index: 100;
}
.sidebar-logo {
  padding: 20px 20px 16px; border-bottom: 1px solid var(--border);
  font-weight: 700; font-size: 18px; color: var(--text);
  display: flex; align-items: center; gap: 10px;
}
.sidebar-logo .logo-icon {
  width: 32px; height: 32px; background: linear-gradient(135deg, #6366f1, #8b5cf6);
  border-radius: 8px; display: flex; align-items: center; justify-content: center;
  font-size: 16px;
}
.sidebar-nav { flex: 1; padding: 12px 0; }
.nav-section { padding: 8px 20px 4px; font-size: 11px; font-weight: 600; color: var(--muted2); text-transform: uppercase; letter-spacing: .6px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 20px; color: var(--muted); text-decoration: none;
  font-size: 14px; font-weight: 500; transition: all .15s;
  border-left: 2px solid transparent; margin: 1px 0;
}
.nav-item:hover { color: var(--text); background: rgba(255,255,255,.04); }
.nav-item.active { color: var(--text); background: rgba(99,102,241,.12); border-left-color: var(--accent); }
.nav-item .icon { font-size: 16px; width: 20px; text-align: center; }

.main-content { margin-left: 240px; flex: 1; min-height: 100vh; }
.topbar {
  background: var(--bg2); border-bottom: 1px solid var(--border);
  padding: 0 28px; height: 60px; display: flex; align-items: center;
  justify-content: space-between; position: sticky; top: 0; z-index: 50;
}
.page-content { padding: 28px; }

/* ── Tables ── */
.table-wrap { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
table { width: 100%; border-collapse: collapse; }
th { background: var(--card2); color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; padding: 12px 16px; text-align: left; }
td { padding: 14px 16px; border-top: 1px solid var(--border); font-size: 14px; vertical-align: middle; }
tr:hover td { background: rgba(255,255,255,.02); }

/* ── Block Editor ── */
.editor-layout { display: flex; gap: 0; height: calc(100vh - 60px); overflow: hidden; }
.blocks-panel { width: 320px; background: var(--bg2); border-right: 1px solid var(--border); display: flex; flex-direction: column; overflow: hidden; }
.blocks-list { flex: 1; overflow-y: auto; padding: 12px; }
.block-item {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px 14px; margin-bottom: 8px;
  cursor: pointer; transition: all .15s; display: flex; align-items: center; gap: 10px;
}
.block-item:hover { border-color: var(--border2); }
.block-item.selected { border-color: var(--accent); background: rgba(99,102,241,.08); }
.block-handle { color: var(--muted2); cursor: grab; font-size: 16px; }
.block-type-icon { font-size: 18px; }
.block-actions { margin-left: auto; display: flex; gap: 4px; opacity: 0; transition: opacity .15s; }
.block-item:hover .block-actions { opacity: 1; }
.btn-icon { background: none; border: none; color: var(--muted); cursor: pointer; padding: 4px; border-radius: 6px; font-size: 14px; transition: all .15s; }
.btn-icon:hover { background: rgba(255,255,255,.08); color: var(--text); }

.preview-panel { flex: 1; background: var(--bg); overflow-y: auto; }
.ai-panel { width: 320px; background: var(--bg2); border-left: 1px solid var(--border); display: flex; flex-direction: column; overflow: hidden; }

/* ── AI Chat ── */
.ai-header { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; }
.ai-messages { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.ai-msg { padding: 10px 14px; border-radius: var(--radius); font-size: 13px; line-height: 1.5; }
.ai-msg.user { background: rgba(99,102,241,.15); border: 1px solid rgba(99,102,241,.2); align-self: flex-end; max-width: 85%; }
.ai-msg.assistant { background: var(--card); border: 1px solid var(--border); align-self: flex-start; max-width: 95%; }
.ai-msg.assistant.success { border-color: rgba(34,197,94,.3); }
.ai-msg.assistant.error { border-color: rgba(239,68,68,.3); }
.ai-input-wrap { padding: 12px; border-top: 1px solid var(--border); display: flex; gap: 8px; align-items: flex-end; }
.ai-input { flex: 1; background: var(--card); border: 1px solid var(--border2); color: var(--text); padding: 10px 14px; border-radius: 18px; font-size: 13px; outline: none; font-family: inherit; resize: none; overflow-y: auto; line-height: 1.5; min-height: 40px; max-height: 160px; display: block; }
.ai-input:focus { border-color: var(--accent); }

/* ── Presets ── */
.preset-row { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.preset-cat { font-size: 10px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .5px; min-width: 36px; flex-shrink: 0; }
.preset-chip { display: inline-flex; align-items: center; padding: 3px 9px; border-radius: 50px; background: rgba(255,255,255,.06); border: 1px solid var(--border2); color: var(--muted); font-size: 11px; cursor: pointer; transition: all .15s; white-space: nowrap; user-select: none; }
.preset-chip:hover { background: rgba(99,102,241,.18); border-color: rgba(99,102,241,.5); color: var(--text); }
.preset-chip:active { transform: scale(.95); }

/* ── Alerts ── */
.alert { padding: 12px 16px; border-radius: var(--radius); font-size: 14px; margin-bottom: 16px; }
.alert-success { background: rgba(34,197,94,.1); border: 1px solid rgba(34,197,94,.25); color: #86efac; }
.alert-error { background: rgba(239,68,68,.1); border: 1px solid rgba(239,68,68,.25); color: #fca5a5; }

/* ── Public Site Styles ── */
.pub-nav {
  position: sticky; top: 0; z-index: 100;
  background: rgba(7,12,24,.85); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border); padding: 0 24px; height: 64px;
  display: flex; align-items: center; justify-content: space-between;
}
.pub-hero {
  min-height: 90vh; display: flex; align-items: center; justify-content: center;
  text-align: center; padding: 80px 24px;
  background: radial-gradient(ellipse 80% 60% at 50% 0%, rgba(99,102,241,.15) 0%, transparent 60%),
              radial-gradient(ellipse 50% 40% at 80% 50%, rgba(6,182,212,.08) 0%, transparent 50%),
              var(--bg);
}
.pub-features-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 20px; }
.pub-cards-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 20px; }
.pub-pricing-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 20px; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }

/* ── Menu burger: hidden on desktop, shown on mobile via media query ── */
#menu-btn { display: none; }

/* ── Sidebar Overlay ── */
.sidebar-overlay {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,.55);
  z-index: 99; backdrop-filter: blur(2px);
}
.sidebar-overlay.active { display: block; }

/* ── Responsive Admin ── */
@media (max-width: 768px) {
  /* Sidebar: slide in/out */
  .sidebar {
    transform: translateX(-100%);
    transition: transform .25s ease;
    z-index: 200;
  }
  .sidebar.open { transform: translateX(0); }

  /* Menu burger button — show via CSS (not inline JS) */
  #menu-btn { display: flex !important; }

  /* Main area: full width */
  .main-content { margin-left: 0; }

  /* Topbar compact */
  .topbar { padding: 0 16px; }

  /* Page content padding */
  .page-content { padding: 16px; }

  /* Tables: horizontal scroll */
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table { min-width: 480px; }

  /* Dashboard grid: stack */
  .dash-grid-2col { grid-template-columns: 1fr !important; }

  /* Stat cards: 2-col on mobile */
  .dash-stats { grid-template-columns: repeat(2, 1fr) !important; }

  /* Editor layout */
  .editor-layout { flex-direction: column; }
  .blocks-panel, .ai-panel { width: 100%; height: 300px; }
}

@media (max-width: 400px) {
  /* Very small phones: stat cards single col */
  .dash-stats { grid-template-columns: 1fr !important; }
}

/* ── Modal responsive (all admin pages) ── */
@media (max-width: 600px) {
  .modal-inner {
    width: calc(100vw - 20px) !important;
    max-width: 100% !important;
    max-height: calc(100dvh - 70px) !important;
    overflow-y: auto !important;
    left: 10px !important;
    right: 10px !important;
    top: 60px !important;
    transform: none !important;
    position: fixed !important;
    margin: 0 !important;
  }
}
