/* ═══════════════════════════════════════════════════
   AutoDM — Dark Industrial Dashboard
   Font: Syne (display) + JetBrains Mono (code)
   Palette: Near-black bg, amber accent, crisp whites
═══════════════════════════════════════════════════ */

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

:root {
  --bg:        #0d0d0f;
  --surface:   #141417;
  --surface2:  #1c1c21;
  --border:    #2a2a32;
  --border2:   #38383f;
  --accent:    #f5a623;
  --accent2:   #e8941a;
  --green:     #22c55e;
  --red:       #ef4444;
  --text:      #f0eff4;
  --text2:     #9998a8;
  --text3:     #6b6a78;
  --mono:      'JetBrains Mono', monospace;
  --sans:      'Syne', sans-serif;
  --radius:    10px;
  --radius-lg: 16px;
  --sidebar-w: 220px;
  --transition: 200ms ease;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ── Shell Layout ──────────────────────────────── */

.shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ── Sidebar ───────────────────────────────────── */

.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 24px 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 20px 24px;
  border-bottom: 1px solid var(--border);
}

.brand-icon {
  width: 36px;
  height: 36px;
  background: var(--accent);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #000;
  flex-shrink: 0;
}

.brand-name {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--text);
}

.nav {
  flex: 1;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius);
  color: var(--text2);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  transition: var(--transition);
}

.nav-item:hover {
  background: var(--surface2);
  color: var(--text);
}

.nav-item.active {
  background: rgba(245, 166, 35, 0.12);
  color: var(--accent);
}

.sidebar-footer {
  padding: 16px 20px 0;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text3);
  font-family: var(--mono);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text3);
  flex-shrink: 0;
  transition: var(--transition);
}
.status-dot.online { background: var(--green); box-shadow: 0 0 6px var(--green); }
.status-dot.error  { background: var(--red); }

/* ── Main ──────────────────────────────────────── */

.main {
  flex: 1;
  overflow-y: auto;
  padding: 40px;
  position: relative;
}

.page { display: none; animation: fadeIn 250ms ease; }
.page.active { display: block; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Page Header ───────────────────────────────── */

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 36px;
  gap: 16px;
}

.page-header h1 {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.8px;
  line-height: 1.1;
}

.subtitle {
  color: var(--text3);
  margin-top: 4px;
  font-size: 13px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.stats-pills {
  display: flex;
  gap: 8px;
}

.stat-pill {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 12px;
  font-family: var(--mono);
  color: var(--text2);
  white-space: nowrap;
}

.stat-pill strong {
  color: var(--accent);
  font-family: var(--mono);
}

/* ── Buttons ───────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: var(--radius);
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 700;
  border: none;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent);
  color: #000;
}
.btn-primary:hover {
  background: var(--accent2);
  transform: translateY(-1px);
}

.btn-ghost {
  background: transparent;
  color: var(--text2);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--surface2); color: var(--text); }

.btn-sm { padding: 7px 14px; font-size: 12px; }

.btn-danger {
  background: rgba(239,68,68,0.1);
  color: var(--red);
  border: 1px solid rgba(239,68,68,0.2);
}
.btn-danger:hover { background: rgba(239,68,68,0.2); }

/* ── Campaigns Grid ────────────────────────────── */

.campaigns-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 20px;
}

.empty-state {
  grid-column: 1/-1;
  text-align: center;
  padding: 80px 40px;
  color: var(--text3);
}

.empty-state svg { opacity: 0.3; margin-bottom: 16px; }
.empty-state h3 { font-size: 18px; color: var(--text2); margin-bottom: 8px; }
.empty-state p { font-size: 13px; }

/* ── Campaign Card ─────────────────────────────── */

.campaign-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: var(--transition);
  animation: slideIn 300ms ease;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

.campaign-card:hover {
  border-color: var(--border2);
  transform: translateY(-2px);
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}

.campaign-card.inactive {
  opacity: 0.55;
}

.card-post-preview {
  height: 100px;
  background: var(--surface2);
  position: relative;
  overflow: hidden;
}

.card-post-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.card-post-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text3);
  background: linear-gradient(135deg, var(--surface2), var(--bg));
}

.card-status-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 10px;
  font-weight: 700;
  font-family: var(--mono);
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.badge-active   { background: rgba(34,197,94,0.2);  color: var(--green); border: 1px solid rgba(34,197,94,0.3); }
.badge-inactive { background: rgba(107,106,120,0.2); color: var(--text3); border: 1px solid var(--border); }

.card-body {
  padding: 16px;
}

.card-name {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-post-id {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text3);
  margin-bottom: 12px;
}

.card-keywords {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 12px;
}

.kw-tag {
  background: rgba(245,166,35,0.08);
  color: var(--accent);
  border: 1px solid rgba(245,166,35,0.2);
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 11px;
  font-family: var(--mono);
}

.card-messages {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}

.msg-row {
  display: flex;
  gap: 8px;
  align-items: flex-start;
}

.msg-icon {
  width: 22px;
  height: 22px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
}

.msg-icon.comment { background: rgba(99,102,241,0.15); color: #818cf8; }
.msg-icon.dm      { background: rgba(245,166,35,0.12); color: var(--accent); }

.msg-text {
  font-size: 12px;
  color: var(--text2);
  line-height: 1.4;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.card-actions {
  display: flex;
  gap: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.card-actions .btn { flex: 1; justify-content: center; }

.toggle-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text2);
  font-size: 12px;
  font-weight: 700;
  padding: 7px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  font-family: var(--sans);
  transition: var(--transition);
}
.toggle-btn:hover { border-color: var(--border2); color: var(--text); }

/* ── Settings ──────────────────────────────────── */

.settings-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  margin-bottom: 20px;
  max-width: 760px;
}

.settings-card-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 28px;
}

.ig-icon {
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, #f09433 0%, #e6683c 25%, #dc2743 50%, #cc2366 75%, #bc1888 100%);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  flex-shrink: 0;
}

.settings-card-header h2 {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.settings-card-header p {
  font-size: 12px;
  color: var(--text3);
  margin-top: 2px;
}

.settings-form { display: flex; flex-direction: column; gap: 20px; }

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-actions { padding-top: 4px; }

/* ── Fields ────────────────────────────────────── */

.field-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-group label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text2);
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

.label-hint {
  font-size: 11px;
  font-weight: 400;
  text-transform: none;
  color: var(--text3);
  letter-spacing: 0;
}

input[type="text"],
input[type="password"],
textarea {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--sans);
  font-size: 13px;
  padding: 10px 14px;
  width: 100%;
  outline: none;
  transition: border-color var(--transition);
  resize: vertical;
}

input:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(245,166,35,0.1);
}

input::placeholder, textarea::placeholder { color: var(--text3); }

.field-hint {
  font-size: 11px;
  color: var(--text3);
  line-height: 1.4;
}

.post-id-row {
  display: flex;
  gap: 8px;
}

.post-id-row input { flex: 1; }

/* ── Keyword Tags ──────────────────────────────── */

.keyword-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  min-height: 0;
}

/* ── Post Preview ──────────────────────────────── */

.post-preview {
  display: flex;
  gap: 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  align-items: flex-start;
}

.post-preview img {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 6px;
  flex-shrink: 0;
}

.post-preview-info { flex: 1; min-width: 0; }

.post-label {
  font-size: 10px;
  font-family: var(--mono);
  color: var(--accent);
  letter-spacing: 1px;
  display: block;
  margin-bottom: 4px;
}

.post-preview-info p {
  font-size: 12px;
  color: var(--text2);
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}

/* ── Toggle ────────────────────────────────────── */

.field-toggle { display: flex; align-items: center; }

.toggle-label {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--text2);
  text-transform: none;
  letter-spacing: 0;
}

.toggle-label input { display: none; }

.toggle-track {
  width: 38px;
  height: 22px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 11px;
  position: relative;
  transition: var(--transition);
}

.toggle-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 14px;
  height: 14px;
  background: var(--text3);
  border-radius: 50%;
  transition: var(--transition);
}

.toggle-label input:checked + .toggle-track {
  background: rgba(245,166,35,0.15);
  border-color: var(--accent);
}

.toggle-label input:checked + .toggle-track .toggle-thumb {
  left: 19px;
  background: var(--accent);
}

/* ── Info Box ──────────────────────────────────── */

.info-box {
  margin-top: 24px;
  background: rgba(245,166,35,0.06);
  border: 1px solid rgba(245,166,35,0.2);
  border-radius: var(--radius);
  padding: 14px 16px;
}

.info-box-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 8px;
}

.info-box p {
  font-size: 12px;
  color: var(--text2);
  line-height: 1.6;
}

.info-box code {
  font-family: var(--mono);
  font-size: 11px;
  background: rgba(255,255,255,0.08);
  padding: 1px 5px;
  border-radius: 3px;
}

/* ── Webhook URL ───────────────────────────────── */

.webhook-url {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
}

.webhook-url code {
  flex: 1;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text2);
  word-break: break-all;
}

.copy-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text2);
  padding: 5px 12px;
  border-radius: 6px;
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}
.copy-btn:hover { background: var(--surface); color: var(--text); }

/* ── Modal ─────────────────────────────────────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 250ms ease;
  padding: 20px;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  transform: scale(0.95) translateY(10px);
  transition: transform 250ms ease;
  box-shadow: 0 24px 80px rgba(0,0,0,0.6);
}

.modal-overlay.open .modal {
  transform: scale(1) translateY(0);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.modal-header h2 {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--text3);
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  display: flex;
  transition: var(--transition);
}
.modal-close:hover { background: var(--surface2); color: var(--text); }

.modal-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-footer {
  display: flex;
  gap: 10px;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  justify-content: flex-end;
  flex-shrink: 0;
}

/* ── Toast ─────────────────────────────────────── */

.toast {
  position: fixed;
  bottom: 32px;
  right: 32px;
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  padding: 12px 20px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  z-index: 200;
  transform: translateY(16px);
  opacity: 0;
  transition: all 300ms ease;
  pointer-events: none;
  max-width: 320px;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

.media-picker { display: flex; flex-direction: column; gap: 10px; }
.media-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  max-height: 220px;
  overflow-y: auto;
}
.media-item {
  position: relative;
  aspect-ratio: 1;
  border-radius: 8px;
  overflow: hidden;
  border: 2px solid transparent;
  cursor: pointer;
  background: var(--surface2);
}
.media-item img { width: 100%; height: 100%; object-fit: cover; }
.media-item.selected { border-color: var(--accent); }
.media-item .media-type {
  position: absolute; bottom: 4px; left: 4px;
  font-size: 9px; font-family: var(--mono);
  background: rgba(0,0,0,0.65); color: #fff; padding: 2px 5px; border-radius: 4px;
}

/* ── Loading Spinner ───────────────────────────── */

.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,0.2);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 600ms linear infinite;
  vertical-align: middle;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Scrollbar ─────────────────────────────────── */

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text3); }

/* ── Responsive ────────────────────────────────── */

/* ── SaaS extras ───────────────────────────────── */

.sidebar-user {
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
}
.status-row { display: flex; align-items: center; gap: 8px; }

.sub-banner {
  margin-bottom: 24px;
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  border: 1px solid var(--border);
}
.sub-banner a { color: var(--accent); font-weight: 700; }
.sub-banner.info { background: rgba(245,166,35,0.08); border-color: rgba(245,166,35,0.25); }
.sub-banner.warn { background: rgba(239,68,68,0.08); border-color: rgba(239,68,68,0.25); }

.pricing-inline {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
  max-width: 900px;
}
.price-card-inline {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.price-inline strong { color: var(--accent); font-size: 28px; font-family: var(--sans); }
.pay-methods-hint {
  grid-column: 1 / -1;
  background: var(--surface2);
  border-radius: var(--radius);
  padding: 14px 16px;
  font-size: 13px;
  color: var(--text2);
}
.pay-methods-hint code, .pay-list code {
  font-family: var(--mono);
  color: var(--accent);
}
.pay-list { margin: 10px 0 0; padding-inline-start: 18px; color: var(--text2); font-size: 13px; }
.payment-history { display: flex; flex-direction: column; gap: 8px; }
.payment-row {
  display: grid;
  grid-template-columns: 80px 120px 80px 100px 1fr;
  gap: 8px;
  padding: 10px 12px;
  background: var(--surface2);
  border-radius: 8px;
  font-size: 12px;
  align-items: center;
}
.mono-sm { font-family: var(--mono); font-size: 11px; color: var(--text3); }
.badge-pending { color: var(--accent); }
.badge-approved { color: var(--green); }
.badge-rejected { color: var(--red); }

select, .filter-select {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--sans);
  font-size: 13px;
  padding: 10px 14px;
  outline: none;
}

.admin-table-wrap { overflow-x: auto; }
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.admin-table th, .admin-table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}
.admin-table th { color: var(--text3); font-size: 11px; text-transform: uppercase; letter-spacing: 0.4px; }

@media (max-width: 768px) {
  .shell { flex-direction: column; }
  .sidebar { width: 100%; min-width: unset; flex-direction: row; padding: 12px 16px; border-right: none; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
  .brand { border-bottom: none; padding-bottom: 0; }
  .nav { flex-direction: row; padding: 0 0 0 16px; flex-wrap: wrap; }
  .sidebar-footer { display: none; }
  .main { padding: 24px 16px; }
  .field-row { grid-template-columns: 1fr; }
  .campaigns-grid { grid-template-columns: 1fr; }
  .page-header { flex-direction: column; gap: 12px; }
  .header-actions { width: 100%; }
  .stats-pills { flex: 1; }
  .payment-row { grid-template-columns: 1fr 1fr; }
}
