/* ============================================================
   SS Watcher — Styles
   Clean, mobile-friendly CSS using custom properties.
   ============================================================ */

:root {
  --bg: #f8f9fa;
  --surface: #ffffff;
  --text: #1a1a1a;
  --text-muted: #6b7280;
  --border: #e5e7eb;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --danger: #dc2626;
  --success: #16a34a;
  --warning: #f59e0b;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

/* ============================================================
   Navbar
   ============================================================ */
.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 56px;
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-brand {
  font-weight: 700;
  font-size: 18px;
  color: var(--primary);
}

.nav-links {
  display: flex;
  list-style: none;
  gap: 4px;
}

.nav-link {
  display: block;
  padding: 8px 16px;
  text-decoration: none;
  color: var(--text-muted);
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
}

.nav-link:hover { background: var(--bg); color: var(--text); }
.nav-link.active { background: var(--primary); color: white; }

.nav-status {
  font-size: 13px;
  color: var(--text-muted);
}

.nav-logout {
  margin-left: 14px;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.nav-logout:hover { background: var(--bg); color: var(--danger); }

/* ============================================================
   Layout
   ============================================================ */
main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px;
}

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

h1 {
  font-size: 24px;
  margin-bottom: 20px;
  color: var(--text);
}

/* ============================================================
   Cards
   ============================================================ */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}

.card-header {
  padding: 14px 20px;
  font-weight: 600;
  font-size: 15px;
  border-bottom: 1px solid var(--border);
}

.card-body { padding: 20px; }

/* ============================================================
   Stats Grid
   ============================================================ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  text-align: center;
}

.stat-value {
  font-size: 32px;
  font-weight: 700;
  color: var(--primary);
}

.stat-label {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ============================================================
   Buttons
   ============================================================ */
.btn {
  display: inline-block;
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  background: var(--surface);
  color: var(--text);
  transition: all 0.15s;
}

.btn:hover { opacity: 0.85; }

.btn-primary { background: var(--primary); color: white; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-hover); }

.btn-danger { background: var(--danger); color: white; border-color: var(--danger); }

.btn-secondary { background: var(--bg); }

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

/* ============================================================
   Forms
   ============================================================ */
.form-row {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  flex-wrap: wrap;
}

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

.form-group label { font-size: 13px; font-weight: 500; margin-bottom: 4px; color: var(--text-muted); }

.form-group input,
.form-group select {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: inherit;
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.flex-grow { flex: 1; }

.form-actions {
  margin-top: 16px;
  display: flex;
  gap: 8px;
}

/* ============================================================
   Tables
   ============================================================ */
.table {
  width: 100%;
  border-collapse: collapse;
}

.table th, .table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

.table th { font-weight: 600; color: var(--text-muted); font-size: 12px; text-transform: uppercase; }

.table tbody tr:hover { background: var(--bg); }

.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }

/* ============================================================
   Ad List
   ============================================================ */
.ad-item {
  display: flex;
  gap: 16px;
  padding: 16px;
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
  cursor: pointer;
}

.ad-item:hover { background: var(--bg); }

.ad-thumb {
  width: 120px;
  height: 90px;
  border-radius: 6px;
  object-fit: cover;
  background: var(--bg);
  flex-shrink: 0;
}

.ad-info { flex: 1; }

.ad-title {
  font-weight: 600;
  font-size: 15px;
  margin-bottom: 4px;
}

.ad-price {
  font-size: 18px;
  font-weight: 700;
  color: var(--success);
  margin-bottom: 6px;
}

.ad-meta {
  display: flex;
  gap: 16px;
  font-size: 13px;
  color: var(--text-muted);
  flex-wrap: wrap;
}

.ad-link {
  color: var(--primary);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
}

.ad-link:hover { text-decoration: underline; }

/* ============================================================
   Pagination
   ============================================================ */
.pagination {
  display: flex;
  gap: 4px;
  margin-top: 16px;
  justify-content: center;
}

.pagination button {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  cursor: pointer;
  font-size: 13px;
}

.pagination button:hover { background: var(--bg); }
.pagination button.active { background: var(--primary); color: white; border-color: var(--primary); }

/* ============================================================
   Badges
   ============================================================ */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
}

.badge-telegram { background: #e0f2fe; color: #0369a1; }
.badge-email { background: #fce7f3; color: #be185d; }
.badge-sent { background: #dcfce7; color: #166534; }
.badge-failed { background: #fee2e2; color: #991b1b; }
.badge-active { background: #dcfce7; color: #166534; }
.badge-inactive { background: #f3f4f6; color: #6b7280; }

/* ============================================================
   Toggle Switch
   ============================================================ */
.toggle {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 22px;
}

.toggle input { opacity: 0; width: 0; height: 0; }

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background: #d1d5db;
  border-radius: 22px;
  transition: 0.2s;
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 16px; width: 16px;
  left: 3px; bottom: 3px;
  background: white;
  border-radius: 50%;
  transition: 0.2s;
}

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

/* ============================================================
   Hamburger menu (mobile)
   ============================================================ */
.nav-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  padding: 4px 8px;
  color: var(--text);
  line-height: 1;
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 768px) {
  .nav-toggle { display: block; }
  .nav-links {
    display: none;
    position: absolute;
    top: 56px;
    left: 0;
    right: 0;
    background: var(--surface);
    flex-direction: column;
    padding: 8px;
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow);
    z-index: 99;
  }
  .nav-links.open { display: flex; }
  .nav-link { border-radius: 6px; }
  .nav-status { font-size: 11px; }
  .nav-brand { font-size: 15px; }
  main { padding: 16px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .ad-item { flex-direction: column; }
  .ad-thumb { width: 100%; height: 180px; }
  .form-row { flex-direction: column; }
  .table { font-size: 12px; }
  .table th, .table td { padding: 6px 4px; }
}
