/* ═══════════════════════════════════════════════════════════════
   Avito XML Generator — Modern UI
   ═══════════════════════════════════════════════════════════════ */

:root {
  --sidebar-w: 248px;
  --sidebar-bg: #0f172a;
  --sidebar-border: rgba(255,255,255,.06);
  --sidebar-text: #94a3b8;
  --sidebar-hover: #1e293b;
  --sidebar-active-bg: #3b82f6;
  --sidebar-active-text: #fff;
  --header-h: 56px;
  --content-bg: #f1f5f9;
  --card-bg: #fff;
  --card-border: #e2e8f0;
  --text-primary: #0f172a;
  --text-secondary: #64748b;
  --accent: #3b82f6;
  --accent-light: #dbeafe;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --radius: 10px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.06);
  --shadow: 0 2px 8px rgba(0,0,0,.08);
}

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: .875rem;
  color: var(--text-primary);
  background: var(--content-bg);
  line-height: 1.5;
}

/* ── Sidebar ─────────────────────────────── */

.sidebar {
  position: fixed;
  left: 0; top: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  z-index: 1050;
  display: flex;
  flex-direction: column;
  transition: transform .25s ease;
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-brand {
  height: var(--header-h);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 10px;
  color: #fff;
  font-weight: 700;
  font-size: 1.05rem;
  border-bottom: 1px solid var(--sidebar-border);
  flex-shrink: 0;
  text-decoration: none;
}
.sidebar-brand:hover { color: #fff; }
.sidebar-brand i { font-size: 1.3rem; color: var(--accent); }

.sidebar-section {
  padding: 16px 12px 4px;
  font-size: .65rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: #475569;
  font-weight: 600;
}

.sidebar-nav {
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 14px;
  color: var(--sidebar-text);
  text-decoration: none;
  border-radius: 8px;
  font-size: .8125rem;
  transition: all .15s;
  white-space: nowrap;
}
.sidebar-link:hover {
  background: var(--sidebar-hover);
  color: #e2e8f0;
}
.sidebar-link.active {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-active-text);
  font-weight: 500;
}
.sidebar-link i {
  font-size: 1.05rem;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}
.sidebar-link .badge {
  margin-left: auto;
  font-size: .65rem;
  padding: 2px 7px;
}

.sidebar-divider {
  height: 1px;
  background: var(--sidebar-border);
  margin: 6px 14px;
}

/* ── Sidebar Overlay (mobile) ────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 1040;
}
.sidebar-overlay.show { display: block; }

/* ── Main Content ────────────────────────── */

.main-wrap {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.main-header {
  height: var(--header-h);
  background: var(--card-bg);
  border-bottom: 1px solid var(--card-border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 1020;
}
.main-header h1 {
  font-size: 1rem;
  font-weight: 600;
  margin: 0;
  white-space: nowrap;
}

.content-area {
  flex: 1;
  padding: 24px;
}

/* ── Cards ───────────────────────────────── */

.card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card-header {
  background: transparent;
  border-bottom: 1px solid var(--card-border);
  padding: 14px 18px;
  font-weight: 600;
  font-size: .875rem;
}
.card-body { padding: 18px; }

/* ── Stat Cards ──────────────────────────── */

.stat-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px;
}
.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
}
.stat-icon.blue   { background: #dbeafe; color: #2563eb; }
.stat-icon.green  { background: #dcfce7; color: #16a34a; }
.stat-icon.purple { background: #f3e8ff; color: #9333ea; }
.stat-icon.amber  { background: #fef3c7; color: #d97706; }
.stat-icon.red    { background: #fee2e2; color: #dc2626; }
.stat-icon.slate  { background: #e2e8f0; color: #475569; }
.stat-value {
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1.2;
}
.stat-label {
  font-size: .75rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* ── Tables ──────────────────────────────── */

.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius);
}
.table {
  margin-bottom: 0;
  font-size: .8125rem;
}
.table th {
  font-weight: 600;
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-secondary);
  background: #f8fafc;
  border-bottom: 2px solid var(--card-border);
  padding: 10px 14px;
  white-space: nowrap;
}
.table td {
  padding: 10px 14px;
  vertical-align: middle;
  border-color: #f1f5f9;
}
.table tbody tr:hover { background: #f8fafc; }

.table-scroll {
  max-height: 60vh;
  overflow-y: auto;
}
.table-scroll thead th {
  position: sticky;
  top: 0;
  z-index: 2;
}

/* ── Avito Ads Generator ───────────────────── */

.generator-path-box {
  padding: 14px 16px;
  border: 1px solid var(--card-border);
  border-radius: 10px;
  background: #f8fafc;
}

.generator-action-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 10px;
}

.preview-card .card-body {
  max-height: 78vh;
  overflow-y: auto;
}

.preview-textarea {
  min-height: 180px;
  white-space: pre-wrap;
}

.preview-textarea-sm {
  min-height: 120px;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 600;
}

.status-ok {
  background: #dcfce7;
  color: #166534;
}

.status-bad {
  background: #fee2e2;
  color: #b91c1c;
}

.warning-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 26px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #fff7ed;
  color: #c2410c;
  font-weight: 700;
  font-size: .72rem;
}

.generator-tabs {
  gap: 10px;
}

.generator-tabs .nav-link {
  border-radius: 999px;
  padding: 10px 18px;
  color: var(--text-secondary);
  background: #fff;
  border: 1px solid var(--card-border);
}

.generator-tabs .nav-link.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.mini-stat {
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 14px 16px;
  background: #f8fafc;
  height: 100%;
}

.mini-stat-label {
  font-size: .72rem;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.mini-stat-value {
  font-size: 1.15rem;
  font-weight: 700;
}

.filter-checks .form-check {
  margin-top: .25rem;
}

.short-scroll {
  max-height: 38vh;
}

.table-title-cell {
  min-width: 260px;
  max-width: 360px;
}

.table-preview-image {
  width: 72px;
  height: 54px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--card-border);
}

.preview-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 10px;
}

.preview-gallery img {
  width: 100%;
  height: 88px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid var(--card-border);
}

.preview-split {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 1rem;
}

.preview-split-card {
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 14px;
  background: #f8fafc;
}

.pricing-overrides-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.form-switch-inline {
  min-height: 38px;
  display: flex;
  align-items: center;
}

@media (max-width: 991.98px) {
  .preview-split {
    grid-template-columns: 1fr;
  }
}

.warning-list {
  padding-left: 1rem;
}

.warning-list li {
  margin-bottom: .35rem;
}

.table-title-cell {
  min-width: 260px;
}

/* ── Buttons ─────────────────────────────── */

.btn { border-radius: 8px; font-size: .8125rem; font-weight: 500; }
.btn-primary { background: var(--accent); border-color: var(--accent); }
.btn-primary:hover { background: #2563eb; border-color: #2563eb; }
.btn-ghost {
  background: transparent;
  border: 1px solid var(--card-border);
  color: var(--text-primary);
}
.btn-ghost:hover { background: #f1f5f9; }

/* ── Progress ────────────────────────────── */

.progress { height: 6px; border-radius: 3px; background: #e2e8f0; }

/* ── Log Area ────────────────────────────── */

.log-area {
  background: #0f172a;
  color: #94a3b8;
  font-family: 'JetBrains Mono', 'Consolas', monospace;
  font-size: .75rem;
  line-height: 1.6;
  padding: 14px;
  border-radius: var(--radius);
  max-height: 300px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
}
.log-area .log-ok { color: #4ade80; }
.log-area .log-warn { color: #fbbf24; }
.log-area .log-err { color: #f87171; }
.log-area .log-info { color: #60a5fa; }

/* ── Badges / Pills ──────────────────────── */

.badge { font-weight: 500; border-radius: 6px; }
.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: .7rem;
  font-weight: 500;
}
.pill-success { background: #dcfce7; color: #166534; }
.pill-warning { background: #fef3c7; color: #92400e; }
.pill-danger  { background: #fee2e2; color: #991b1b; }
.pill-info    { background: #dbeafe; color: #1e40af; }
.pill-neutral { background: #f1f5f9; color: #475569; }

/* ── Forms ───────────────────────────────── */

.form-control, .form-select {
  border-radius: 8px;
  border-color: var(--card-border);
  font-size: .8125rem;
}
.form-control:focus, .form-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(59,130,246,.15);
}
.form-label {
  font-size: .8125rem;
  font-weight: 500;
  margin-bottom: 4px;
}

/* ── Drag & Drop Zone ────────────────────── */

.drop-zone {
  border: 2px dashed var(--card-border);
  border-radius: var(--radius);
  padding: 32px;
  text-align: center;
  cursor: pointer;
  transition: all .2s;
  color: var(--text-secondary);
}
.drop-zone:hover, .drop-zone.drag-over {
  border-color: var(--accent);
  background: var(--accent-light);
  color: var(--accent);
}

/* ── Photo Grid ──────────────────────────── */

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
}
.photo-card {
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--card-border);
  background: var(--card-bg);
}
.photo-card img {
  width: 100%;
  height: 120px;
  object-fit: cover;
}
.photo-card-info {
  padding: 6px 8px;
  font-size: .7rem;
  color: var(--text-secondary);
}

/* ── Alert customization ─────────────────── */

.alert { border-radius: var(--radius); font-size: .8125rem; }

/* ── Code blocks ─────────────────────────── */

code {
  font-size: .78rem;
  color: #b45309;
  background: #fef3c7;
  padding: 1px 5px;
  border-radius: 4px;
}
pre code { background: none; color: inherit; padding: 0; }

/* ── Toast notifications ─────────────────── */

.toast-container {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 1100;
}

/* ── Empty state ─────────────────────────── */

.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-secondary);
}
.empty-state i {
  font-size: 3rem;
  margin-bottom: 12px;
  opacity: .3;
}
.empty-state p { margin-top: 8px; }

/* ── Responsive ──────────────────────────── */

@media (max-width: 991.98px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.show { transform: translateX(0); }
  .main-wrap { margin-left: 0; }
  .content-area { padding: 16px; }
}

@media (max-width: 575.98px) {
  .stat-card { padding: 14px; }
  .stat-value { font-size: 1.3rem; }
}

/* ═══ Dark Mode ══════════════════════════════ */

[data-bs-theme="dark"] {
  --content-bg: #0c1222;
  --card-bg: #1e293b;
  --card-border: #334155;
  --text-primary: #e2e8f0;
  --text-secondary: #94a3b8;
  --sidebar-bg: #020617;
  --sidebar-hover: #0f172a;
}

[data-bs-theme="dark"] .main-header {
  background: #1e293b;
  border-color: #334155;
}

[data-bs-theme="dark"] .table th { background: #0f172a; }
[data-bs-theme="dark"] .table td { border-color: #1e293b; }
[data-bs-theme="dark"] .table tbody tr:hover { background: #0f172a; }

[data-bs-theme="dark"] .form-control,
[data-bs-theme="dark"] .form-select {
  background: #0f172a;
  border-color: #334155;
  color: #e2e8f0;
}

[data-bs-theme="dark"] .drop-zone {
  border-color: #334155;
}
[data-bs-theme="dark"] .drop-zone:hover,
[data-bs-theme="dark"] .drop-zone.drag-over {
  background: rgba(59,130,246,.1);
}

[data-bs-theme="dark"] code {
  background: #1c1917;
  color: #fbbf24;
}

[data-bs-theme="dark"] .stat-icon.blue   { background: rgba(37,99,235,.15); }
[data-bs-theme="dark"] .stat-icon.green  { background: rgba(22,163,74,.15); }
[data-bs-theme="dark"] .stat-icon.purple { background: rgba(147,51,234,.15); }
[data-bs-theme="dark"] .stat-icon.amber  { background: rgba(217,119,6,.15); }
[data-bs-theme="dark"] .stat-icon.red    { background: rgba(220,38,38,.15); }
[data-bs-theme="dark"] .stat-icon.slate  { background: rgba(71,85,105,.2); }

[data-bs-theme="dark"] .pill-success { background: rgba(22,101,52,.2); color: #86efac; }
[data-bs-theme="dark"] .pill-warning { background: rgba(146,64,14,.2); color: #fcd34d; }
[data-bs-theme="dark"] .pill-danger  { background: rgba(153,27,27,.2); color: #fca5a5; }
[data-bs-theme="dark"] .pill-info    { background: rgba(30,64,175,.2); color: #93c5fd; }
[data-bs-theme="dark"] .pill-neutral { background: rgba(71,85,105,.2); color: #94a3b8; }

[data-bs-theme="dark"] .photo-card { border-color: #334155; }
