@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@400;500;600;700;800;900&family=Open+Sans:wght@300;400;500;600&display=swap');

:root {
  --bg: #0d0d0d;
  --surface: #161616;
  --surface2: #1f1f1f;
  --surface3: #2a2a2a;
  --border: #2e2e2e;
  --border2: #3a3a3a;
  --orange: #ff6a00;
  --orange2: #ff8c38;
  --orange-glow: rgba(255,106,0,.18);
  --orange-dim: rgba(255,106,0,.08);
  --white: #ffffff;
  --text: #f0f0f0;
  --text2: #b0b0b0;
  --muted: #6a6a6a;
  --green: #22c55e;
  --green-dim: rgba(34,197,94,.1);
  --red: #ef4444;
  --red-dim: rgba(239,68,68,.1);
  --sidebar: 260px;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Open Sans', sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1,h2,h3,h4,h5,.font-heading { font-family: 'Montserrat', sans-serif; }

a { text-decoration: none; color: inherit; }

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

/* ─── SIDEBAR ────────────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 200;
  transition: transform .3s ease;
}

.sidebar-logo {
  padding: 24px 22px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}
.logo-icon {
  width: 36px; height: 36px;
  background: var(--orange);
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
}
.logo-text {
  font-family: 'Montserrat', sans-serif;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--white);
}
.logo-text span { color: var(--orange); }
.logo-badge {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--orange);
  background: var(--orange-dim);
  border: 1px solid rgba(255,106,0,.25);
  padding: 2px 6px;
  border-radius: 4px;
  margin-left: 4px;
}

.nav { flex: 1; padding: 16px 12px; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.nav-section {
  font-family: 'Montserrat', sans-serif;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .15em;
  color: var(--muted);
  padding: 14px 10px 6px;
}
.nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text2);
  font-size: 13px;
  font-weight: 500;
  transition: all .15s;
  position: relative;
}
.nav a .nav-icon { font-size: 16px; width: 22px; text-align: center; flex-shrink: 0; }
.nav a:hover { background: var(--surface2); color: var(--text); }
.nav a.active {
  background: var(--orange-dim);
  color: var(--orange);
  font-weight: 600;
}
.nav a.active::before {
  content: '';
  position: absolute;
  left: 0; top: 50%;
  transform: translateY(-50%);
  width: 3px; height: 20px;
  background: var(--orange);
  border-radius: 0 3px 3px 0;
}

.sidebar-footer { padding: 12px; border-top: 1px solid var(--border); }
.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--surface2);
  border: 1px solid var(--border);
}
.avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--orange);
  display: flex; align-items: center; justify-content: center;
  font-family: 'Montserrat', sans-serif;
  font-weight: 800;
  font-size: 13px;
  color: var(--white);
  flex-shrink: 0;
}
.avatar.admin-av { background: linear-gradient(135deg, #ff6a00, #ff8c38); }
.user-name { font-size: 13px; font-weight: 600; font-family: 'Montserrat', sans-serif; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.logout-btn {
  display: block;
  text-align: center;
  padding: 8px;
  color: var(--muted);
  font-size: 12px;
  border-radius: var(--radius-sm);
  margin-top: 6px;
  cursor: pointer;
  background: none;
  border: none;
  width: 100%;
  transition: all .15s;
  font-family: 'Open Sans', sans-serif;
}
.logout-btn:hover { color: var(--red); background: var(--red-dim); }

/* Mobile sidebar overlay */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.7);
  z-index: 190;
  backdrop-filter: blur(2px);
}
.sidebar-overlay.open { display: block; }

/* ─── MOBILE HEADER ──────────────────────────────────────────────────────────── */
.mobile-header {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 56px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  z-index: 180;
  padding: 0 16px;
  align-items: center;
  justify-content: space-between;
}
.hamburger {
  background: none;
  border: none;
  color: var(--text);
  font-size: 22px;
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
}
.mobile-logo {
  font-family: 'Montserrat', sans-serif;
  font-size: 18px;
  font-weight: 800;
  color: var(--white);
}
.mobile-logo span { color: var(--orange); }

/* ─── MAIN LAYOUT ────────────────────────────────────────────────────────────── */
.with-sidebar {
  margin-left: var(--sidebar);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  padding: 18px 28px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 100;
}
.page-title {
  font-family: 'Montserrat', sans-serif;
  font-size: 18px;
  font-weight: 700;
  color: var(--white);
}

.content { padding: 24px 28px; flex: 1; }

/* ─── CARDS ──────────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
}
.card-title {
  font-family: 'Montserrat', sans-serif;
  font-weight: 700;
  font-size: 14px;
  color: var(--white);
  margin-bottom: 16px;
  text-transform: uppercase;
  letter-spacing: .05em;
}

/* ─── FORMS ──────────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 14px; }
.form-label {
  display: block;
  font-family: 'Montserrat', sans-serif;
  font-size: 10px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .1em;
  margin-bottom: 7px;
}
input, select, textarea {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  color: var(--text);
  font-family: 'Open Sans', sans-serif;
  font-size: 14px;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
  -webkit-appearance: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--orange);
  box-shadow: 0 0 0 3px var(--orange-dim);
}
input[type=date] { color-scheme: dark; }
select option { background: var(--surface2); }

/* ─── BUTTONS ────────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  border: none;
  font-family: 'Montserrat', sans-serif;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all .2s;
  text-decoration: none;
  white-space: nowrap;
  letter-spacing: .02em;
}
.btn-primary {
  background: var(--orange);
  color: var(--white);
}
.btn-primary:hover {
  background: var(--orange2);
  box-shadow: 0 4px 20px rgba(255,106,0,.35);
  transform: translateY(-1px);
}
.btn-secondary {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border2);
}
.btn-secondary:hover { border-color: var(--orange); color: var(--orange); }
.btn-danger {
  background: var(--red-dim);
  color: var(--red);
  border: 1px solid rgba(239,68,68,.2);
}
.btn-danger:hover { background: rgba(239,68,68,.2); }
.btn-green {
  background: var(--green-dim);
  color: var(--green);
  border: 1px solid rgba(34,197,94,.2);
}
.btn-green:hover { background: rgba(34,197,94,.2); }
.btn-sm { padding: 7px 13px; font-size: 11px; border-radius: 7px; }
.btn-xs { padding: 5px 10px; font-size: 10px; border-radius: 6px; }
.btn-icon { width: 36px; height: 36px; padding: 0; border-radius: 8px; font-size: 15px; }

/* ─── BADGES ─────────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 100px;
  font-family: 'Montserrat', sans-serif;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .03em;
}
.badge-orange { background: var(--orange-dim); color: var(--orange); border: 1px solid rgba(255,106,0,.2); }
.badge-green { background: var(--green-dim); color: var(--green); border: 1px solid rgba(34,197,94,.2); }
.badge-red { background: var(--red-dim); color: var(--red); border: 1px solid rgba(239,68,68,.2); }
.badge-gray { background: var(--surface3); color: var(--text2); }
.badge-white { background: rgba(255,255,255,.08); color: var(--text); }

/* ─── TABLE ──────────────────────────────────────────────────────────────────── */
table { width: 100%; border-collapse: collapse; }
th {
  font-family: 'Montserrat', sans-serif;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--muted);
  font-weight: 700;
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
td { padding: 12px 14px; border-bottom: 1px solid rgba(46,46,46,.5); font-size: 13px; vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(255,106,0,.03); }

/* ─── MODAL ──────────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.85);
  z-index: 300;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(6px);
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: var(--radius-lg);
  padding: 28px;
  width: 500px;
  max-width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  animation: slideUp .25s ease both;
}
.modal-wide { width: 680px; }
.modal-title {
  font-family: 'Montserrat', sans-serif;
  font-weight: 800;
  font-size: 18px;
  color: var(--white);
  margin-bottom: 20px;
}
.modal-footer { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; }
@keyframes slideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }

/* ─── TOAST ──────────────────────────────────────────────────────────────────── */
#toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  padding: 13px 20px;
  font-size: 13px;
  font-family: 'Montserrat', sans-serif;
  font-weight: 600;
  opacity: 0;
  transition: all .3s;
  transform: translateY(10px);
  box-shadow: 0 20px 50px rgba(0,0,0,.6);
  max-width: 320px;
}
#toast.show { opacity: 1; transform: translateY(0); }
#toast.success { border-color: rgba(34,197,94,.3); color: var(--green); }
#toast.error { border-color: rgba(239,68,68,.3); color: var(--red); }

/* ─── GRID ───────────────────────────────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3,1fr); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4,1fr); gap: 14px; }

/* ─── STAT CARD ──────────────────────────────────────────────────────────────── */
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  position: relative;
  overflow: hidden;
}
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--orange);
  opacity: 0;
  transition: opacity .2s;
}
.stat-card:hover::before { opacity: 1; }
.stat-value {
  font-family: 'Montserrat', sans-serif;
  font-size: 32px;
  font-weight: 800;
  color: var(--white);
  line-height: 1;
  margin-bottom: 6px;
}
.stat-label { font-size: 12px; color: var(--muted); font-weight: 500; }

/* ─── PAGE RESULT CARD ───────────────────────────────────────────────────────── */
.page-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: all .2s;
  position: relative;
}
.page-card:hover { border-color: var(--orange); box-shadow: 0 8px 32px rgba(255,106,0,.12); }
.page-card.inactive { opacity: .7; border-style: dashed; }
.page-card-header {
  padding: 16px 18px 14px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  border-bottom: 1px solid var(--border);
}
.page-thumb-wrap {
  width: 60px;
  height: 60px;
  border-radius: 10px;
  overflow: hidden;
  background: var(--surface3);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
}
.page-thumb-wrap img { width: 100%; height: 100%; object-fit: cover; }
.page-info { flex: 1; min-width: 0; }
.page-name {
  font-family: 'Montserrat', sans-serif;
  font-weight: 700;
  font-size: 15px;
  color: var(--white);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 6px;
}
.page-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.active-indicator { display: flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 600; font-family: 'Montserrat', sans-serif; }
.dot-active { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 8px var(--green); animation: pulse 2s infinite; }
.dot-inactive { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
@keyframes pulse { 0%,100%{box-shadow:0 0 4px var(--green)} 50%{box-shadow:0 0 12px var(--green)} }
.ad-count-big {
  font-family: 'Montserrat', sans-serif;
  font-size: 28px;
  font-weight: 900;
  color: var(--orange);
  line-height: 1;
  text-align: right;
}
.ad-count-label { font-size: 10px; color: var(--muted); text-align: right; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }

.page-card-actions {
  padding: 14px 18px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

/* Preview thumbnails */
.page-previews {
  display: flex;
  gap: 4px;
  padding: 0 18px 14px;
}
.preview-thumb {
  flex: 1;
  height: 55px;
  border-radius: 6px;
  overflow: hidden;
  background: var(--surface3);
  max-width: 80px;
}
.preview-thumb img { width: 100%; height: 100%; object-fit: cover; }
.preview-more {
  flex: 1;
  height: 55px;
  border-radius: 6px;
  background: var(--surface3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Montserrat', sans-serif;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  max-width: 80px;
}

/* ─── SPINNER ────────────────────────────────────────────────────────────────── */
.spinner { display: inline-block; width: 32px; height: 32px; border: 3px solid var(--border2); border-top-color: var(--orange); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.empty-state { text-align: center; padding: 60px 20px; color: var(--muted); }
.empty-icon { font-size: 48px; margin-bottom: 16px; }
.empty-title { font-family: 'Montserrat', sans-serif; font-size: 16px; font-weight: 700; color: var(--text2); margin-bottom: 8px; }
.empty-sub { font-size: 13px; }

/* ─── RESPONSIVE ─────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .with-sidebar { margin-left: 0; padding-top: 56px; }
  .mobile-header { display: flex; }
  .topbar { display: none; }
  .content { padding: 16px; }
  .grid-4 { grid-template-columns: repeat(2,1fr); gap: 10px; }
  .grid-3 { grid-template-columns: repeat(2,1fr); }
  .grid-2 { grid-template-columns: 1fr; }
  .filters-row { grid-template-columns: 1fr 1fr !important; }
  .filters-row2 { grid-template-columns: 1fr 1fr !important; }
  .modal { padding: 20px; }
  .page-card-actions { gap: 6px; }
  .btn { font-size: 12px; padding: 9px 14px; }
  .stat-value { font-size: 26px; }
  #toast { bottom: 16px; right: 16px; left: 16px; max-width: none; }
}

@media (max-width: 480px) {
  .grid-4 { grid-template-columns: 1fr 1fr; }
  .page-card-header { flex-wrap: wrap; }
}

/* ─── SEARCH RESULTS GRID ────────────────────────────────────────────────────── */
.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}
@media (max-width: 768px) {
  .results-grid { grid-template-columns: 1fr; gap: 12px; }
}

/* ─── DIVIDER ────────────────────────────────────────────────────────────────── */
.divider { display: flex; align-items: center; gap: 12px; margin: 20px 0; }
.divider span { font-family: 'Montserrat', sans-serif; font-size: 10px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .1em; white-space: nowrap; }
.divider::before,.divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }
