/*  REBATE Design System — Components
    All components use tokens from tokens.css — never hardcoded colors.
*/

/* ══════════════════════════════════════════════
   BUTTONS
   Priority: default (grey), action (green), destructive (red), ghost
   Sizes: sm, md (default), lg
   States: default, hover, active, disabled
   Variants: text, icon-left, icon-right, dropdown, icon-only
   ══════════════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  font-weight: var(--weight-bold);
  line-height: 20px;
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--text-primary);
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--duration-base) var(--ease-default);
  white-space: nowrap;
  user-select: none;
}
.btn:hover { background: var(--bg-hover); border-color: var(--border-strong); }
.btn:active { background: var(--bg-active); }
.btn:disabled, .btn.disabled {
  opacity: 0.35;
  cursor: not-allowed;
  pointer-events: none;
}

/* Action (green) — primary positive CTA */
.btn--action {
  background: linear-gradient(180deg, #05C56B 0%, #00933E 100%);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 2px 10px 0 rgba(5, 197, 107, 0.60);
}
.btn--action:hover { background: linear-gradient(180deg, #06d475 0%, #00a847 100%); }
.btn--action:active { background: linear-gradient(180deg, #04b060 0%, #008236 100%); }
.btn--action:disabled, .btn--action.disabled { box-shadow: none; }

/* Destructive (red/crimson) */
.btn--destructive {
  background: linear-gradient(180deg, #E3284C 0%, #AA0024 100%);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 2px 10px 0 rgba(227, 40, 76, 0.60);
}
.btn--destructive:hover { background: linear-gradient(180deg, #f03058 0%, #bf002a 100%); }
.btn--destructive:active { background: linear-gradient(180deg, #cc2343 0%, #96001f 100%); }
.btn--destructive:disabled, .btn--destructive.disabled { box-shadow: none; }

/* Ghost — no background */
.btn--ghost {
  background: transparent;
  border-color: transparent;
}
.btn--ghost:hover { background: var(--bg-hover); }

/* Sizes */
.btn--sm { padding: var(--space-1) var(--space-3); font-size: var(--text-xs); }
.btn--lg { padding: var(--space-3) var(--space-6); font-size: var(--text-base); }

/* Icon-only */
.btn--icon {
  width: 36px; height: 36px;
  padding: 0;
}
.btn--icon.btn--sm { width: 28px; height: 28px; }

/* Dropdown chevron */
.btn__chevron {
  font-size: 10px;
  opacity: 0.8;
}

/* ══════════════════════════════════════════════
   BADGES / TAGS
   Variants: default, accent, success, warning, danger, gold
   ══════════════════════════════════════════════ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 2px var(--space-2);
  font-size: var(--text-xs);
  font-weight: var(--weight-semi);
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  border: 1px solid var(--border-default);
}
.badge--accent   { background: var(--accent-primary-muted); color: var(--accent-primary); border-color: var(--accent-primary); }
.badge--gold     { background: var(--accent-secondary-muted); color: var(--accent-secondary); border-color: var(--accent-secondary); }
.badge--success  { background: var(--color-success-muted); color: var(--color-success); border-color: var(--color-success); }
.badge--warning  { background: var(--color-warning-muted); color: var(--color-warning); border-color: var(--color-warning); }
.badge--danger   { background: var(--color-danger-muted); color: var(--color-danger); border-color: var(--color-danger); }
.badge--info     { background: var(--color-info-muted); color: var(--color-info); border-color: var(--color-info); }
.badge--ai       { background: var(--color-info-muted); color: var(--color-info); border-color: var(--color-info); cursor: help; }

.badge .badge__dismiss {
  cursor: pointer;
  opacity: 0.6;
  margin-left: var(--space-1);
}
.badge .badge__dismiss:hover { opacity: 1; }

/* ══════════════════════════════════════════════
   TAG (larger, with type:detail pattern)
   ══════════════════════════════════════════════ */
.tag {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-3);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  color: var(--text-primary);
}
.tag__type {
  font-size: var(--text-xs);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: var(--tracking-caps);
}
.tag--accent { border-color: var(--accent-primary); }
.tag--accent .tag__type { color: var(--accent-primary); }

/* ══════════════════════════════════════════════
   CARDS
   ══════════════════════════════════════════════ */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  transition: border-color var(--duration-base) var(--ease-default);
}
.card:hover { border-color: var(--border-default); }
.card--interactive { cursor: pointer; }
.card--interactive:hover { border-color: var(--border-strong); }
.card--interactive:active { border-color: var(--accent-primary); box-shadow: var(--accent-primary-glow); }

.card--elevated {
  background: var(--bg-elevated);
  box-shadow: var(--shadow-md);
}

.card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
}
.card__title {
  font-size: var(--text-md);
  font-weight: var(--weight-semi);
}
.card__subtitle {
  font-size: var(--text-sm);
  color: var(--text-muted);
}

/* ══════════════════════════════════════════════
   INPUTS
   ══════════════════════════════════════════════ */
.input {
  width: 100%;
  padding: var(--space-2) var(--space-3);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  color: var(--input-text);
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: var(--radius-md);
  outline: none;
  transition: all var(--duration-base) var(--ease-default);
}
.input::placeholder { color: var(--input-placeholder); }
.input:hover { background: var(--input-bg-hover); }
.input:focus {
  background: var(--input-bg-focus);
  border-color: var(--input-border-focus);
  box-shadow: var(--accent-primary-glow);
}

.input-group {
  position: relative;
  display: flex;
  align-items: center;
}
.input-group__icon {
  position: absolute;
  left: var(--space-3);
  color: var(--text-muted);
  pointer-events: none;
}
.input-group .input { padding-left: var(--space-8); }

/* ── Select (with left accent bar on active) ── */
.select {
  appearance: none;
  padding-right: var(--space-8);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b6e7f' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--space-3) center;
}

.select-option {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-left: 3px solid transparent;
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-default);
}
.select-option:hover { background: var(--bg-hover); }
.select-option.active {
  background: var(--bg-active);
  border-left-color: var(--accent-primary);
  font-weight: var(--weight-semi);
}

/* ══════════════════════════════════════════════
   TABLE
   ══════════════════════════════════════════════ */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}
.table th {
  text-align: left;
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-xs);
  font-weight: var(--weight-semi);
  text-transform: uppercase;
  letter-spacing: var(--tracking-caps);
  color: var(--text-muted);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-default);
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
}
.table td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
}
.table tr:hover td { background: var(--bg-hover); }
.table tr.active td { background: var(--accent-primary-muted); }

/* ── Metric cell (value + label) ── */
.metric {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.metric__value {
  font-size: var(--text-md);
  font-weight: var(--weight-bold);
  letter-spacing: var(--tracking-tight);
}
.metric__label {
  font-size: var(--text-xs);
  font-weight: var(--weight-semi);
  text-transform: uppercase;
  letter-spacing: var(--tracking-caps);
}
.metric__label--success { color: var(--color-success); }
.metric__label--warning { color: var(--color-warning); }
.metric__label--danger  { color: var(--color-danger); }
.metric__label--gold    { color: var(--accent-secondary); }

/* ══════════════════════════════════════════════
   SCORE BAR (pillar visualization)
   ══════════════════════════════════════════════ */
.score-bar {
  height: 6px;
  background: var(--border-subtle);
  border-radius: var(--radius-pill);
  overflow: hidden;
}
.score-bar__fill {
  height: 100%;
  border-radius: var(--radius-pill);
  transition: width var(--duration-slow) var(--ease-default);
}

/* Segmented bar (multi-color, like generation distribution) */
.segmented-bar {
  display: flex;
  height: 6px;
  border-radius: var(--radius-pill);
  overflow: hidden;
  gap: 1px;
}
.segmented-bar__segment {
  height: 100%;
  transition: width var(--duration-slow) var(--ease-default);
}

/* ══════════════════════════════════════════════
   SIDEBAR NAV
   ══════════════════════════════════════════════ */
/* Sidebar base — see dashboard.css for full sidebar styles */

/* ══════════════════════════════════════════════
   OVERLAY / MODAL
   ══════════════════════════════════════════════ */
.overlay {
  position: fixed;
  inset: 0;
  background: var(--overlay-bg);
  z-index: var(--z-overlay);
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal {
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  padding: var(--space-6);
  max-width: 560px;
  width: 90%;
  max-height: 85vh;
  overflow-y: auto;
}
.modal--lg { min-width: 700px; max-width: 1240px; width: 90%; }

/* ══════════════════════════════════════════════
   ICONS (Lucide)
   ══════════════════════════════════════════════ */
.icon { width: 16px; height: 16px; stroke-width: 2; flex-shrink: 0; }
.icon--sm { width: 14px; height: 14px; }
.icon--lg { width: 20px; height: 20px; }
.icon--xl { width: 24px; height: 24px; }

/* ══════════════════════════════════════════════
   COUNTRY FLAG BADGE
   ══════════════════════════════════════════════ */
.country-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-3);
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: var(--weight-semi);
}
.country-badge__flag { font-size: var(--text-lg); }

/* ══════════════════════════════════════════════
   SPARKLINE (inline mini chart)
   ══════════════════════════════════════════════ */
.sparkline {
  display: inline-block;
  width: 64px;
  height: 24px;
}
.sparkline svg { width: 100%; height: 100%; }
.sparkline path {
  fill: none;
  stroke: var(--accent-secondary);
  stroke-width: 1.5;
}

/* ══════════════════════════════════════════════
   THEME TOGGLE
   ══════════════════════════════════════════════ */
.theme-toggle {
  width: 44px; height: 24px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-pill);
  cursor: pointer;
  position: relative;
  transition: background var(--duration-base) var(--ease-default);
}
.theme-toggle::after {
  content: '';
  position: absolute;
  top: 3px; left: 3px;
  width: 16px; height: 16px;
  background: var(--text-primary);
  border-radius: var(--radius-round);
  transition: transform var(--duration-base) var(--ease-default);
}
:root[data-theme="light"] .theme-toggle::after {
  transform: translateX(20px);
}

/* ══════════════════════════════════════════════
   UTILITY CLASSES
   ══════════════════════════════════════════════ */
.text-xs     { font-size: var(--text-xs); }
.text-sm     { font-size: var(--text-sm); }
.text-base   { font-size: var(--text-base); }
.text-lg     { font-size: var(--text-lg); }
.text-xl     { font-size: var(--text-xl); }
.text-2xl    { font-size: var(--text-2xl); }
.text-3xl    { font-size: var(--text-3xl); }

.text-primary   { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-muted     { color: var(--text-muted); }
.text-accent    { color: var(--accent-primary); }
.text-gold      { color: var(--accent-secondary); }
.text-success   { color: var(--color-success); }
.text-warning   { color: var(--color-warning); }
.text-danger    { color: var(--color-danger); }

.font-display { font-family: var(--font-display); }
.font-medium { font-weight: var(--weight-medium); }
.font-semi   { font-weight: var(--weight-semi); }
.font-bold   { font-weight: var(--weight-bold); }

.caps {
  text-transform: uppercase;
  letter-spacing: var(--tracking-caps);
  font-size: var(--text-xs);
  font-weight: var(--weight-semi);
}

.flex        { display: flex; }
.flex-col    { flex-direction: column; }
.items-center{ align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1  { gap: var(--space-1); }
.gap-2  { gap: var(--space-2); }
.gap-3  { gap: var(--space-3); }
.gap-4  { gap: var(--space-4); }
.gap-6  { gap: var(--space-6); }

.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
