/* ==========================================================================
   TDG LiveRamp Analytics — Theme Tokens
   Dark is the default; [data-theme="light"] on <html> swaps the palette.
   ========================================================================== */

/* ---------- Dark Theme (default) ---------- */
:root {
  --bg-primary: #0b1120;
  --bg-secondary: #111827;
  --bg-card: rgba(17, 24, 39, 0.8);
  --nav-bg: rgba(11, 17, 32, 0.85);
  --border: rgba(55, 65, 81, 0.5);
  --border-strong: rgba(55, 65, 81, 0.7);
  --border-subtle: rgba(55, 65, 81, 0.25);
  --hover-bg: rgba(255, 255, 255, 0.06);
  --hover-bg-soft: rgba(255, 255, 255, 0.04);
  --table-row-hover: rgba(255, 255, 255, 0.03);
  --shadow: rgba(0, 0, 0, 0.4);
  --scrollbar-thumb: rgba(255, 255, 255, 0.1);
  --scrollbar-thumb-hover: rgba(255, 255, 255, 0.2);

  --text-primary: #f9fafb;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;
  --text-on-accent: #ffffff;

  --accent-green: #7cc576;
  --accent-green-hover: #4a9e47;
  --accent-green-soft: rgba(124, 197, 118, 0.15);
  --accent-green-border: rgba(124, 197, 118, 0.3);
  --accent-blue: #3b82f6;
  --accent-purple: #8b5cf6;
  --accent-amber: #d4b94e;
  --accent-cyan: #06b6d4;
  --accent-rose: #f43f5e;
  --accent-red: #ef4444;
  --accent-red-border: rgba(239, 68, 68, 0.4);
  --accent-green-status: #22c55e;
  --accent-yellow: #eab308;

  --badge-green-bg: rgba(34, 197, 94, 0.12);
  --badge-yellow-bg: rgba(234, 179, 8, 0.12);
  --badge-red-bg: rgba(239, 68, 68, 0.12);

  --radius: 12px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: "SF Mono", "Fira Code", "Fira Mono", Menlo, Consolas, monospace;
}

/* ---------- Light Theme ---------- */
:root[data-theme="light"] {
  --bg-primary: #f1f5f9;
  --bg-secondary: #ffffff;
  --bg-card: rgba(255, 255, 255, 0.92);
  --nav-bg: rgba(248, 250, 252, 0.9);
  --border: rgba(15, 23, 42, 0.12);
  --border-strong: rgba(15, 23, 42, 0.18);
  --border-subtle: rgba(15, 23, 42, 0.08);
  --hover-bg: rgba(15, 23, 42, 0.06);
  --hover-bg-soft: rgba(15, 23, 42, 0.04);
  --table-row-hover: rgba(15, 23, 42, 0.03);
  --shadow: rgba(15, 23, 42, 0.12);
  --scrollbar-thumb: rgba(15, 23, 42, 0.18);
  --scrollbar-thumb-hover: rgba(15, 23, 42, 0.32);

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --text-on-accent: #ffffff;

  /* Accents tuned for legibility on a white background */
  --accent-green: #16a34a;
  --accent-green-hover: #15803d;
  --accent-green-soft: rgba(22, 163, 74, 0.12);
  --accent-green-border: rgba(22, 163, 74, 0.4);
  --accent-blue: #2563eb;
  --accent-purple: #7c3aed;
  --accent-amber: #b45309;
  --accent-cyan: #0891b2;
  --accent-rose: #e11d48;
  --accent-red: #dc2626;
  --accent-red-border: rgba(220, 38, 38, 0.45);
  --accent-green-status: #16a34a;
  --accent-yellow: #a16207;

  --badge-green-bg: rgba(22, 163, 74, 0.15);
  --badge-yellow-bg: rgba(161, 98, 7, 0.15);
  --badge-red-bg: rgba(220, 38, 38, 0.12);
}

/* ---------- 1. Reset / Base ---------- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

img { max-width: 100%; display: block; }
button { cursor: pointer; font-family: inherit; }

/* ---------- 2. Layout ---------- */
.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
}

.grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
}

.flex-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* ---------- 3. Nav ---------- */
#navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--nav-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.nav-inner {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: 56px;
}

.nav-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.nav-logo {
  height: 36px;
  width: auto;
}

.nav-brand {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.nav-brand-name {
  font-weight: 700;
  font-size: 14px;
  color: var(--text-primary);
}

.nav-brand-sub {
  font-size: 11px;
  color: var(--text-muted);
}

.nav-client-label {
  font-size: 12px;
  color: var(--accent-green);
  margin-left: 8px;
  padding: 2px 10px;
  border: 1px solid var(--accent-green-border);
  border-radius: 9999px;
}

.nav-client-label:empty { display: none; }

.nav-right {
  display: flex;
  align-items: center;
  gap: 4px;
}

.nav-link {
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
}

.nav-link:hover,
.nav-link.active {
  color: var(--text-primary);
  background: var(--hover-bg);
}

/* Dropdown */
.nav-dropdown {
  position: relative;
}

.nav-dropdown-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  padding: 8px 14px;
  transition: color 0.15s;
}

.nav-dropdown-btn:hover {
  color: var(--text-primary);
}

.nav-chevron {
  transition: transform 0.2s;
}

.nav-dropdown.open .nav-chevron {
  transform: rotate(180deg);
}

.nav-dropdown-menu {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 160px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px;
  z-index: 50;
  box-shadow: 0 10px 25px var(--shadow);
}

.nav-dropdown.open .nav-dropdown-menu {
  display: block;
}

.nav-dropdown-item {
  display: block;
  padding: 8px 12px;
  font-size: 13px;
  color: var(--text-secondary);
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
}

.nav-dropdown-item:hover {
  color: var(--text-primary);
  background: var(--hover-bg);
}

.nav-dropdown-divider {
  height: 1px;
  margin: 6px 0;
  background: var(--border);
  opacity: 0.6;
}

/* Status indicator */
.nav-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-muted);
  margin-left: 12px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-green-status);
  animation: pulse 2s ease-in-out infinite;
}

.nav-theme-btn {
  margin-left: 8px;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  color: var(--text-secondary);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
  line-height: 1;
}

.nav-theme-btn:hover {
  color: var(--text-primary);
  background: var(--hover-bg);
}

/* Show the icon corresponding to the theme we'd switch TO. */
.nav-theme-btn .theme-icon-light { display: none; }
.nav-theme-btn .theme-icon-dark  { display: inline; }
:root[data-theme="light"] .nav-theme-btn .theme-icon-dark  { display: none; }
:root[data-theme="light"] .nav-theme-btn .theme-icon-light { display: inline; }

.nav-logout-btn {
  margin-left: 12px;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  transition: color 0.15s, border-color 0.15s;
}

.nav-logout-btn:hover {
  color: var(--accent-rose);
  border-color: var(--accent-rose);
}

/* ---------- 4. Glass Card ---------- */
.glass-card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}

/* ---------- 5. Typography ---------- */
h1 { font-size: 28px; font-weight: 700; }
h2 { font-size: 22px; font-weight: 600; }
h3 { font-size: 18px; font-weight: 600; }
h4 { font-size: 15px; font-weight: 600; }

/* Login page */
.login-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 80px);
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 380px;
  padding: 40px 32px;
}

.login-header {
  text-align: center;
  margin-bottom: 32px;
}

.login-logo {
  width: 56px;
  height: 56px;
  margin: 0 auto 16px;
  display: block;
}

.login-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0 0 4px;
}

.login-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0;
}

.login-error {
  color: var(--accent-rose);
  font-size: 13px;
  min-height: 20px;
  margin-bottom: 8px;
}

.login-footer {
  margin-top: 32px;
  text-align: center;
}

.text-xs  { font-size: 11px; }
.text-sm  { font-size: 13px; }
.text-mono { font-family: var(--font-mono); font-size: 13px; }
.text-muted { color: var(--text-muted); }
.text-accent { color: var(--accent-green); }

/* ---------- 6. Forms ---------- */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"],
input[type="number"],
select,
textarea {
  width: 100%;
  padding: 10px 14px;
  font-size: 14px;
  font-family: var(--font);
  color: var(--text-primary);
  background: var(--bg-secondary);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent-green);
  box-shadow: 0 0 0 3px var(--accent-green-soft);
}

::placeholder {
  color: var(--text-muted);
}

label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-on-accent);
  background: var(--accent-green);
  border: none;
  border-radius: 8px;
  transition: background 0.15s, transform 0.1s;
}

.btn:hover {
  background: var(--accent-green-hover);
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--accent-green);
  color: var(--text-on-accent);
}

.btn-full {
  width: 100%;
  cursor: pointer;
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
}

.btn-outline:hover {
  border-color: var(--text-secondary);
  color: var(--text-primary);
  background: var(--hover-bg-soft);
}

/* ---------- 7. Loading / Error ---------- */
.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 0;
  gap: 16px;
  color: var(--text-muted);
  font-size: 14px;
}

.spinner,
.loading-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--accent-green);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* Inline variant — small enough to sit next to a label in a flex row. */
.loading-spinner.inline {
  width: 16px;
  height: 16px;
  border-width: 2px;
  display: inline-block;
  vertical-align: middle;
}

.error-card {
  background: var(--bg-card);
  border: 1px solid var(--accent-red-border);
  border-radius: var(--radius);
  padding: 24px;
  color: var(--accent-red);
}

/* ---------- 8. Data Display ---------- */
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.stat-value {
  font-size: 32px;
  font-weight: 700;
  line-height: 1;
  margin-bottom: 4px;
}

.stat-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

/* ---------- 9. Tables ---------- */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

thead th {
  text-align: left;
  padding: 10px 14px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

tbody td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-secondary);
}

tbody tr:hover {
  background: var(--table-row-hover);
}

/* ---------- 10. Animations ---------- */
@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.animate-in {
  animation: fadeInUp 0.35s ease-out both;
}

.bar-fill {
  transition: width 0.6s ease-out;
}

/* ---------- 11. Scrollbar ---------- */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--scrollbar-thumb-hover);
}

/* ---------- 12. Responsive ---------- */
@media (max-width: 1024px) {
  .grid-4 {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .grid-2,
  .grid-4 {
    grid-template-columns: 1fr;
  }

  .nav-inner {
    padding: 0 16px;
  }

  .nav-right .nav-link,
  .nav-dropdown,
  .nav-status {
    display: none;
  }

  .nav-logout-btn {
    margin-left: auto;
  }

  .container {
    padding: 16px;
  }
}

/* ---------- 13. Badges ---------- */
.badge {
  display: inline-block;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 9999px;
}

.badge-green {
  color: var(--accent-green-status);
  background: var(--badge-green-bg);
}

.badge-yellow {
  color: var(--accent-yellow);
  background: var(--badge-yellow-bg);
}

.badge-red {
  color: var(--accent-red);
  background: var(--badge-red-bg);
}

/* ---------- 14. Timeline ---------- */
.timeline {
  position: relative;
  padding-left: 24px;
}

.timeline::before {
  content: "";
  position: absolute;
  left: 7px;
  top: 4px;
  bottom: 4px;
  width: 2px;
  background: var(--border);
}

.timeline-item {
  position: relative;
  padding-bottom: 20px;
}

.timeline-item:last-child {
  padding-bottom: 0;
}

.timeline-dot {
  position: absolute;
  left: -20px;
  top: 6px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent-blue);
  border: 2px solid var(--bg-primary);
}

.timeline-dot.dot-green  { background: var(--accent-green-status); }
.timeline-dot.dot-yellow { background: var(--accent-yellow); }
.timeline-dot.dot-red    { background: var(--accent-red); }
.timeline-dot.dot-purple { background: var(--accent-purple); }

.timeline-time {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.timeline-content {
  font-size: 13px;
  color: var(--text-secondary);
}

/* ---------- 15. Utility ---------- */
.hidden {
  display: none;
}

/* Consistent minimalist drill-through affordance used across list pages
   (advertisers/agencies/platforms/audiences) + admin + taxonomy. */
.drill-link {
  color: var(--accent-blue);
  font-size: 0.72rem;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  opacity: 0.85;
  transition: opacity 0.12s;
}
.drill-link:hover {
  opacity: 1;
  text-decoration: underline;
}
