/* =====================================================
   Ads Reports Dashboard — design system
   Modern SaaS look, RTL-aware, no framework dependency.
   ===================================================== */

:root {
  --bg:           #f4f6fb;
  --surface:      #ffffff;
  --surface-2:    #f8fafc;
  --border:       #e5e9f2;
  --border-strong:#d6dbe7;
  --text:         #0f172a;
  --text-muted:   #64748b;
  --primary:      #4f46e5;
  --primary-700:  #4338ca;
  --primary-50:   #eef2ff;
  --success:      #10b981;
  --warning:      #f59e0b;
  --danger:       #ef4444;

  --radius:       14px;
  --radius-sm:    10px;
  --shadow:       0 1px 2px rgba(15,23,42,.04), 0 6px 20px rgba(15,23,42,.05);
  --shadow-soft:  0 1px 2px rgba(15,23,42,.04);
  --gap:          16px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Heebo', 'Rubik', system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0 0 8px; font-weight: 600; }
h1 { font-size: 22px; }
h2 { font-size: 17px; }
a  { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--text-muted); }
.small { font-size: 12px; }
.note  { margin-top: 18px; font-size: 12px; }
hr { border: 0; border-top: 1px solid var(--border); margin: 16px 0; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 16px; border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font: inherit; font-weight: 500; cursor: pointer;
  background: var(--surface-2); color: var(--text);
  transition: background .15s ease, transform .05s ease, box-shadow .15s ease;
}
.btn:hover { background: #eef0f6; }
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: var(--primary); color: #fff;
  box-shadow: 0 4px 16px rgba(79,70,229,.25);
}
.btn-primary:hover { background: var(--primary-700); }
.btn-ghost {
  background: transparent; border-color: var(--border);
}
.btn-ghost:hover { background: var(--surface-2); }
.btn-link {
  background: none; border: 0; color: var(--primary); cursor: pointer;
  padding: 4px 6px; font: inherit;
}
.btn-link:hover { text-decoration: underline; }

/* ---------- inputs ---------- */
input, select, textarea {
  font: inherit; color: var(--text);
  background: #fff;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  outline: none; width: 100%;
  transition: border-color .15s ease, box-shadow .15s ease;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-50);
}
label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--text-muted); }
label > input, label > select { color: var(--text); }
.select-control { min-width: 160px; }

/* ---------- card ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 18px;
}
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.card-header h2 { margin: 0; }

/* ---------- pills ---------- */
.pill {
  display: inline-block; padding: 2px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 500;
}
.pill-success { background: #dcfce7; color: #047857; }
.pill-muted   { background: #e2e8f0; color: #475569; }

/* ---------- chips (filter buttons) ---------- */
.chip {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 13px;
  cursor: pointer;
}
.chip:hover { background: #eef0f6; }
.chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}
.data-table th, .data-table td {
  padding: 12px 14px;
  text-align: start;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table th {
  font-weight: 600;
  font-size: 12px;
  color: var(--text-muted);
  background: var(--surface-2);
  text-transform: uppercase;
  letter-spacing: .03em;
}
.data-table tbody tr:hover { background: var(--surface-2); }
.row-actions { display: flex; gap: 6px; }
.row-logo { width: 32px; height: 32px; border-radius: 8px; object-fit: cover; }
.row-mono {
  width: 32px; height: 32px; border-radius: 8px;
  background: var(--primary-50); color: var(--primary);
  display: grid; place-items: center; font-weight: 600;
}

/* ---------- KPI grid ---------- */
.kpi-grid {
  display: grid; gap: var(--gap);
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  margin-bottom: 18px;
}
.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  padding: 18px 20px;
  display: flex; flex-direction: column; gap: 6px;
}
.kpi-label { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; }
.kpi-value { font-size: 26px; font-weight: 700; }
.kpi-sub   { font-size: 12px; color: var(--text-muted); }

/* ---------- topbar (client dashboard) ---------- */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 14px 28px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; position: sticky; top: 0; z-index: 5;
}
.topbar-left { display: flex; align-items: center; gap: 14px; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.brand-logo { width: 40px; height: 40px; object-fit: cover; border-radius: 10px; }
.brand-mono {
  width: 40px; height: 40px; border-radius: 10px;
  background: var(--primary-50); color: var(--primary);
  display: grid; place-items: center; font-size: 18px; font-weight: 700;
}
.brand-title { font-weight: 600; }
.brand-sub   { font-size: 12px; }
.user-chip   {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 13px; color: var(--text);
}

/* ---------- container ---------- */
.container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 22px;
}

/* ---------- filter row ---------- */
.filter-row {
  display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: var(--gap);
}
.filter-dates { display: flex; flex-wrap: wrap; align-items: end; gap: 10px; }
.filter-dates input { min-width: 150px; }
.filter-platforms { display: flex; flex-wrap: wrap; gap: 6px; }
.quick-ranges { display: flex; gap: 6px; margin-inline-start: 8px; }

/* ---------- auth screens ---------- */
.auth-body {
  min-height: 100vh; display: grid; place-items: center;
  background: linear-gradient(180deg, #eef2ff 0%, #f4f6fb 60%);
  padding: 24px;
}
.auth-card {
  width: 100%; max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 32px;
  box-shadow: 0 6px 24px rgba(15,23,42,.08);
}
.auth-card-wide { max-width: 720px; }
.auth-brand { text-align: center; margin-bottom: 22px; }
.auth-brand h1 { font-size: 22px; }
.logo-dot {
  width: 36px; height: 36px;
  background: var(--primary);
  border-radius: 10px; margin: 0 auto 10px;
  box-shadow: 0 4px 16px rgba(79,70,229,.3);
}
.auth-card form { display: flex; flex-direction: column; gap: 12px; }
.auth-card .btn { justify-content: center; }
.auth-foot { margin-top: 18px; text-align: center; font-size: 12px; }
.form-msg { min-height: 18px; font-size: 13px; }
.form-msg.error { color: var(--danger); }
.form-msg.success { color: var(--success); }

.client-grid {
  display: grid; gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  margin-top: 14px;
}
.client-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 14px;
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  text-align: center; color: var(--text);
  transition: border-color .15s ease, transform .1s ease;
}
.client-card:hover { border-color: var(--primary); transform: translateY(-2px); text-decoration: none; }
.client-card img { width: 56px; height: 56px; border-radius: 12px; object-fit: cover; }
.client-mono {
  width: 56px; height: 56px; border-radius: 12px;
  background: var(--primary-50); color: var(--primary);
  display: grid; place-items: center; font-weight: 700; font-size: 22px;
}

/* ---------- admin layout ---------- */
.admin-body {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}
.sidebar {
  background: #0f172a;
  color: #cbd5e1;
  padding: 20px 16px;
  display: flex; flex-direction: column;
  gap: 14px;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  font-weight: 600; color: #fff; padding: 4px 6px;
}
.sidebar-brand .logo-dot { margin: 0; width: 28px; height: 28px; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; margin-top: 8px; }
.sidebar nav a {
  color: #cbd5e1;
  padding: 9px 12px;
  border-radius: 10px;
  font-size: 14px;
}
.sidebar nav a:hover { background: rgba(255,255,255,.05); text-decoration: none; }
.sidebar nav a.active { background: var(--primary); color: #fff; }
.sidebar-foot {
  margin-top: auto;
  font-size: 12px;
  display: flex; flex-direction: column; gap: 8px;
  border-top: 1px solid rgba(255,255,255,.08);
  padding-top: 14px;
}
.sidebar-foot a { color: #93c5fd; }

.admin-main { background: var(--bg); }
.admin-top {
  background: var(--surface);
  padding: 18px 28px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 4;
}
.admin-content {
  padding: 22px 28px;
  max-width: 1200px;
}
.actions-bar { display: flex; justify-content: flex-end; margin-bottom: 14px; }

/* ---------- forms ---------- */
.form-card form { display: flex; flex-direction: column; gap: 14px; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px,1fr)); gap: 12px; align-items: end; }
.form-actions { display: flex; align-items: center; gap: 10px; margin-top: 6px; }
.logo-preview { width: 64px; height: 64px; border-radius: 12px; object-fit: cover; align-self: end; }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .admin-body { grid-template-columns: 1fr; }
  .sidebar {
    flex-direction: row; flex-wrap: wrap;
    padding: 12px 16px; gap: 8px;
  }
  .sidebar nav { flex-direction: row; flex-wrap: wrap; }
  .sidebar-foot { flex-direction: row; margin-top: 0; padding-top: 0; border: 0; }
  .topbar { padding: 14px 16px; flex-wrap: wrap; }
  .container, .admin-content { padding: 16px; }
}
