/* ============================================================
   Instagram Auto-DM Dashboard — styles
   ============================================================ */

:root {
  --bg: #0f0f0f;
  --surface: #1a1a1a;
  --surface2: #242424;
  --border: #2e2e2e;
  --accent: #e1306c;
  --accent-hover: #c1184e;
  --accent2: #833ab4;
  --green: #2ecc71;
  --yellow: #f39c12;
  --red: #e74c3c;
  --text: #f0f0f0;
  --text-muted: #888;
  --radius: 10px;
  --font: "Inter", system-ui, sans-serif;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.6;
  min-height: 100vh;
}

/* ---- Layout ---- */
.layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: 100vh;
}

/* ---- Sidebar ---- */
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 24px 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-logo {
  padding: 0 20px 20px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}

.sidebar-logo h1 {
  font-size: 16px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.sidebar-logo p {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  cursor: pointer;
  color: var(--text-muted);
  border-radius: 0;
  transition: background 0.15s, color 0.15s;
  border-left: 3px solid transparent;
  font-weight: 500;
}

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

.nav-item svg { flex-shrink: 0; }

.sidebar-status {
  margin-top: auto;
  padding: 16px 20px;
  border-top: 1px solid var(--border);
}

.status-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-right: 6px;
}
.status-dot.online { background: var(--green); box-shadow: 0 0 6px var(--green); }
.status-dot.offline { background: var(--red); }

/* ---- Main content ---- */
.main {
  padding: 32px;
  overflow-y: auto;
}

.page { display: none; }
.page.active { display: block; }

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
}

.page-header h2 { font-size: 22px; font-weight: 700; }
.page-header p { color: var(--text-muted); font-size: 13px; margin-top: 2px; }

/* ---- Stat cards ---- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.stat-card .label {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}

.stat-card .value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
}

.stat-card .value.accent { color: var(--accent); }
.stat-card .value.green { color: var(--green); }

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: background 0.15s, opacity 0.15s;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: var(--accent-hover); }

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

.btn-danger {
  background: transparent;
  color: var(--red);
  border: 1px solid var(--red);
}
.btn-danger:hover { background: var(--red); color: #fff; }

.btn-sm { padding: 5px 10px; font-size: 12px; }

.btn:disabled { opacity: 0.45; cursor: not-allowed; }

/* ---- Cards / Tables ---- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
}

.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
}

th {
  text-align: left;
  padding: 10px 20px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
}

td {
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--surface2); }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}

.badge-green { background: rgba(46,204,113,.15); color: var(--green); }
.badge-red { background: rgba(231,76,60,.15); color: var(--red); }
.badge-yellow { background: rgba(243,156,18,.15); color: var(--yellow); }
.badge-muted { background: var(--surface2); color: var(--text-muted); }

/* ---- Forms ---- */
.form-grid {
  display: grid;
  gap: 16px;
}

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

label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

input, textarea, select {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 10px 12px;
  font-size: 14px;
  font-family: var(--font);
  width: 100%;
  transition: border-color 0.15s;
  outline: none;
}

input:focus, textarea:focus, select:focus {
  border-color: var(--accent);
}

textarea { resize: vertical; min-height: 80px; }

.form-hint { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.toggle-row:last-child { border-bottom: none; }

/* Toggle switch */
.toggle {
  position: relative;
  width: 40px; height: 22px;
  flex-shrink: 0;
}

.toggle input { display: none; }

.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--border);
  border-radius: 22px;
  cursor: pointer;
  transition: background 0.2s;
}

.toggle-slider::after {
  content: "";
  position: absolute;
  top: 3px; left: 3px;
  width: 16px; height: 16px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
}

.toggle input:checked + .toggle-slider { background: var(--accent); }
.toggle input:checked + .toggle-slider::after { transform: translateX(18px); }

/* ---- Modal ---- */
.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.65);
  backdrop-filter: blur(4px);
  z-index: 100;
  align-items: center;
  justify-content: center;
}

.modal-backdrop.open { display: flex; }

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 28px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.modal-header h3 { font-size: 18px; font-weight: 700; }

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 22px;
  cursor: pointer;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 4px;
}

.modal-close:hover { background: var(--surface2); color: var(--text); }

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 24px;
}

/* ---- Empty state ---- */
.empty {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}

.empty svg { margin-bottom: 12px; opacity: 0.35; }
.empty p { font-size: 14px; }

/* ---- Toast ---- */
#toast-container {
  position: fixed;
  bottom: 24px; right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 999;
}

.toast {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 18px;
  font-size: 13px;
  min-width: 240px;
  box-shadow: 0 4px 24px rgba(0,0,0,.4);
  animation: slideIn 0.2s ease;
}

.toast.success { border-left: 3px solid var(--green); }
.toast.error { border-left: 3px solid var(--red); }
.toast.info { border-left: 3px solid var(--accent); }

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

/* ---- Misc ---- */
.text-muted { color: var(--text-muted); }
.monospace { font-family: monospace; font-size: 12px; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 260px; }

@media (max-width: 700px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .main { padding: 16px; }
}
