/* ========================================
   Postulage Dashboard — CSS
   Light/Dark, Responsive, BEM-lite
   ======================================== */

/* --- Variables (aligned with CV site) --- */
:root,
[data-theme="light"] {
  --bg: #ffffff;
  --bg-alt: #f8f9fa;
  --text: #1a1a2e;
  --text-muted: #5a5a7a;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --border: #e2e8f0;
  --card-bg: #ffffff;
  --card-shadow: 0 1px 3px rgba(0,0,0,0.08);
  --tag-bg: #e8eef6;
  --tag-text: #2563eb;
  --badge-bg: #dbeafe;
  --badge-text: #1e40af;
  --nav-bg: rgba(255,255,255,0.85);
  --timeline-line: #cbd5e1;
  --timeline-dot: #2563eb;

  /* Status colors */
  --status-identified: #6366f1;
  --status-applied: #2563eb;
  --status-screening: #f59e0b;
  --status-interview: #8b5cf6;
  --status-offer: #10b981;
  --status-accepted: #059669;
  --status-rejected: #ef4444;
  --status-withdrawn: #6b7280;
  --status-expired: #9ca3af;

  /* Priority colors */
  --priority-high: #ef4444;
  --priority-medium: #f59e0b;
  --priority-low: #6b7280;

  /* Dashboard-specific */
  --kanban-col-bg: var(--bg-alt);
  --panel-width: 28rem;
  --panel-shadow: -4px 0 24px rgba(0,0,0,0.12);
  --stale-bg: #fef2f2;
  --stale-border: #fecaca;
  --stale-text: #991b1b;
}

[data-theme="dark"] {
  --bg: #0f172a;
  --bg-alt: #1e293b;
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --accent: #60a5fa;
  --accent-hover: #93c5fd;
  --border: #334155;
  --card-bg: #1e293b;
  --card-shadow: 0 1px 3px rgba(0,0,0,0.3);
  --tag-bg: #1e3a5f;
  --tag-text: #93c5fd;
  --badge-bg: #1e3a5f;
  --badge-text: #93c5fd;
  --nav-bg: rgba(15,23,42,0.85);
  --timeline-line: #334155;
  --timeline-dot: #60a5fa;

  --status-identified: #818cf8;
  --status-applied: #60a5fa;
  --status-screening: #fbbf24;
  --status-interview: #a78bfa;
  --status-offer: #34d399;
  --status-accepted: #6ee7b7;
  --status-rejected: #f87171;
  --status-withdrawn: #9ca3af;
  --status-expired: #6b7280;

  --priority-high: #f87171;
  --priority-medium: #fbbf24;
  --priority-low: #9ca3af;

  --kanban-col-bg: var(--bg-alt);
  --stale-bg: #1c1917;
  --stale-border: #7f1d1d;
  --stale-text: #fca5a5;
}

/* --- Reset --- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* --- Skip link (a11y) --- */
.skip-link {
  position: absolute;
  top: -100%;
  left: 1rem;
  background: var(--accent);
  color: #fff;
  padding: 0.5rem 1rem;
  border-radius: 0.25rem;
  z-index: 1000;
  text-decoration: none;
  font-size: 0.875rem;
}
.skip-link:focus {
  top: 0.5rem;
}

/* --- Base --- */
html {
  scroll-behavior: smooth;
}
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  font-size: 0.9375rem;
  min-height: 100vh;
}
.container {
  max-width: 90rem;
  margin: 0 auto;
  padding: 0 1rem;
}

/* --- Nav --- */
.nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--nav-bg);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 0.5rem 0;
}
.nav__inner {
  max-width: 90rem;
  margin: 0 auto;
  padding: 0 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.nav__logo {
  font-weight: 700;
  font-size: 1.125rem;
  color: var(--accent);
  letter-spacing: -0.02em;
}
.nav__controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* --- View toggle --- */
.view-toggle {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 0.375rem;
  overflow: hidden;
}
.view-toggle__btn {
  padding: 0.375rem 0.75rem;
  font-size: 0.8125rem;
  font-family: inherit;
  background: transparent;
  color: var(--text-muted);
  border: none;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.view-toggle__btn:hover {
  background: var(--bg-alt);
}
.view-toggle__btn--active {
  background: var(--accent);
  color: #fff;
}

/* --- Theme toggle (from CV) --- */
.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: 0.375rem;
  padding: 0.375rem;
  cursor: pointer;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, border-color 0.15s;
}
.theme-toggle:hover {
  color: var(--accent);
  border-color: var(--accent);
}
[data-theme="light"] .theme-toggle__moon { display: none; }
[data-theme="dark"] .theme-toggle__sun { display: none; }

/* --- Export button --- */
.btn {
  padding: 0.375rem 0.75rem;
  font-size: 0.8125rem;
  font-family: inherit;
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 0.375rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
}
.btn:hover {
  background: var(--bg-alt);
  color: var(--text);
}
.btn--success {
  background: var(--status-offer);
  color: #fff;
  border-color: var(--status-offer);
}

/* --- Loading / Error --- */
.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  gap: 1rem;
  color: var(--text-muted);
}
.loading__spinner {
  width: 2rem;
  height: 2rem;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
.error {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--status-rejected);
}

/* --- Stats bar --- */
.stats {
  background: var(--bg-alt);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 0;
}
.stats__grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.25rem;
  align-items: center;
}
.stats__item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.125rem;
  min-width: 3.5rem;
}
.stats__value {
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.2;
}
.stats__label {
  font-size: 0.6875rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.stats__sep {
  width: 1px;
  height: 2rem;
  background: var(--border);
}

/* --- Filters --- */
.filters {
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
}
.filters__inner {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}
.filters__group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  align-items: center;
}
.filters__label {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-right: 0.25rem;
}
.filters__sep {
  width: 1px;
  height: 1.5rem;
  background: var(--border);
  margin: 0 0.25rem;
}

/* Filter pills */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.625rem;
  font-size: 0.75rem;
  font-family: inherit;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.pill:hover {
  border-color: var(--accent);
  color: var(--text);
}
.pill--active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.pill__dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  display: inline-block;
}

/* Search input */
.filters__search {
  padding: 0.3125rem 0.625rem;
  font-size: 0.8125rem;
  font-family: inherit;
  border: 1px solid var(--border);
  border-radius: 0.375rem;
  background: var(--bg);
  color: var(--text);
  min-width: 10rem;
  outline: none;
  transition: border-color 0.15s;
}
.filters__search:focus {
  border-color: var(--accent);
}
.filters__search::placeholder {
  color: var(--text-muted);
}

/* Active-only toggle */
.toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  cursor: pointer;
}
.toggle__switch {
  width: 2rem;
  height: 1.125rem;
  background: var(--border);
  border-radius: 999px;
  position: relative;
  transition: background 0.15s;
}
.toggle__switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 0.875rem;
  height: 0.875rem;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.15s;
}
.toggle--active .toggle__switch {
  background: var(--accent);
}
.toggle--active .toggle__switch::after {
  transform: translateX(0.875rem);
}

/* --- Kanban --- */
.kanban {
  display: flex;
  gap: 0.625rem;
  padding: 1rem 0;
  overflow-x: auto;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
  min-height: calc(100vh - 16rem);
}
.kanban__column {
  flex: 0 0 auto;
  min-width: 15rem;
  max-width: 20rem;
  display: flex;
  flex-direction: column;
  border-radius: 0.5rem;
  background: var(--kanban-col-bg);
  scroll-snap-align: start;
}
.kanban__header {
  padding: 0.5rem 0.75rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 2px solid var(--col-color, var(--border));
  position: sticky;
  top: 0;
  z-index: 2;
}
.kanban__title {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text);
}
.kanban__count {
  font-size: 0.75rem;
  font-weight: 700;
  background: var(--bg);
  color: var(--text-muted);
  border-radius: 999px;
  padding: 0.125rem 0.5rem;
  min-width: 1.5rem;
  text-align: center;
}
.kanban__cards {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.5rem;
  max-height: calc(100vh - 20rem);
}
.kanban__empty {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: center;
  padding: 1rem 0.5rem;
  font-style: italic;
}

/* --- Card --- */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 0.375rem;
  padding: 0.625rem 0.75rem;
  cursor: pointer;
  transition: box-shadow 0.15s, border-color 0.15s;
}
.card:hover,
.card:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  outline: none;
}
.card--stale {
  background: var(--stale-bg);
  border-color: var(--stale-border);
}
.card__header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
}
.card__company {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
}
.card__role {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.375rem;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.5rem;
  font-size: 0.6875rem;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}
.card__footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.6875rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}
.card__salary {
  font-weight: 600;
  color: var(--status-offer);
}
.card__stale {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.625rem;
  color: var(--stale-text);
  background: var(--stale-bg);
  border: 1px solid var(--stale-border);
  border-radius: 999px;
  padding: 0.125rem 0.5rem;
  margin-top: 0.25rem;
}

/* --- Badge --- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.125rem 0.5rem;
  font-size: 0.625rem;
  font-weight: 600;
  border-radius: 999px;
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.badge--high { background: rgba(239,68,68,0.12); color: var(--priority-high); }
.badge--medium { background: rgba(245,158,11,0.12); color: var(--priority-medium); }
.badge--low { background: rgba(107,114,128,0.12); color: var(--priority-low); }
.badge--type {
  background: var(--tag-bg);
  color: var(--tag-text);
  text-transform: none;
  font-weight: 500;
}
.badge--status {
  text-transform: capitalize;
}

/* --- Tag --- */
.tag {
  display: inline-flex;
  align-items: center;
  padding: 0.1875rem 0.5rem;
  font-size: 0.6875rem;
  background: var(--tag-bg);
  color: var(--tag-text);
  border-radius: 0.25rem;
  white-space: nowrap;
}

/* --- Table view --- */
.table-view {
  padding: 1rem 0;
  overflow-x: auto;
}
.table-view__table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
}
.table-view__table th {
  text-align: left;
  padding: 0.5rem 0.625rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  transition: color 0.15s;
}
.table-view__table th:hover {
  color: var(--accent);
}
.table-view__table th .sort-arrow {
  display: inline-block;
  margin-left: 0.25rem;
  font-size: 0.625rem;
  opacity: 0.4;
}
.table-view__table th .sort-arrow--active {
  opacity: 1;
  color: var(--accent);
}
.table-view__table td {
  padding: 0.5rem 0.625rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.table-view__table tr {
  cursor: pointer;
  transition: background 0.1s;
}
.table-view__table tbody tr:hover {
  background: var(--bg-alt);
}
.table-view__table .tr--stale {
  background: var(--stale-bg);
}

/* --- Detail panel --- */
.detail-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: var(--panel-width);
  max-width: 100vw;
  background: var(--card-bg);
  border-left: 1px solid var(--border);
  box-shadow: var(--panel-shadow);
  z-index: 200;
  overflow-y: auto;
  padding: 1.5rem;
  transform: translateX(0);
}
/* Panel transitions */
.detail-panel--enter {
  transition: transform 0.2s ease-out;
}
.detail-panel--leave {
  transition: transform 0.15s ease-in;
}
.detail-panel--enter-start {
  transform: translateX(100%);
}
.detail-panel--enter-end {
  transform: translateX(0);
}
.detail-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.3);
  z-index: 199;
}
[data-theme="dark"] .detail-backdrop {
  background: rgba(0, 0, 0, 0.5);
}
.detail-panel__header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.detail-panel__title {
  flex: 1;
}
.detail-panel__company {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.25rem;
}
.detail-panel__role {
  font-size: 0.875rem;
  color: var(--text-muted);
}
.detail-panel__close {
  background: none;
  border: 1px solid var(--border);
  border-radius: 0.375rem;
  padding: 0.25rem 0.5rem;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 1rem;
  line-height: 1;
  flex-shrink: 0;
  transition: color 0.15s, border-color 0.15s;
}
.detail-panel__close:hover {
  color: var(--text);
  border-color: var(--text);
}

/* Detail: info grid */
.detail-info {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.375rem 0.75rem;
  font-size: 0.8125rem;
  margin-bottom: 1.25rem;
}
.detail-info__label {
  color: var(--text-muted);
  font-weight: 500;
}
.detail-info__value {
  color: var(--text);
}
.detail-info__value a {
  color: var(--accent);
  text-decoration: none;
}
.detail-info__value a:hover {
  text-decoration: underline;
}

/* Detail: criteria match */
.detail-criteria {
  margin-bottom: 1.25rem;
}
.detail-criteria__title {
  font-size: 0.8125rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--text);
}
.detail-criteria__grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}
.criteria-item {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.75rem;
}
.criteria-item__dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  flex-shrink: 0;
}
.criteria-item__dot--good { background: var(--status-offer); }
.criteria-item__dot--ok { background: var(--status-screening); }
.criteria-item__dot--bad { background: var(--status-rejected); }
.criteria-item__dot--unknown { background: var(--text-muted); }

/* Detail: tags */
.detail-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-bottom: 1.25rem;
}

/* Detail: timeline */
.detail-timeline {
  margin-top: 1rem;
}
.detail-timeline__title {
  font-size: 0.8125rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
  color: var(--text);
}
.timeline-event {
  position: relative;
  padding-left: 1.5rem;
  padding-bottom: 1rem;
  border-left: 2px solid var(--timeline-line);
}
.timeline-event:last-child {
  border-left-color: transparent;
  padding-bottom: 0;
}
.timeline-event__dot {
  position: absolute;
  left: -0.375rem;
  top: 0.25rem;
  width: 0.75rem;
  height: 0.75rem;
  border-radius: 50%;
  border: 2px solid var(--card-bg);
}
.timeline-event__header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
}
.timeline-event__date {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text);
}
.timeline-event__type {
  font-size: 0.625rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.0625rem 0.375rem;
  border-radius: 0.25rem;
  background: var(--tag-bg);
  color: var(--tag-text);
}
.timeline-event__notes {
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.5;
}

/* --- Charts --- */
.charts {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
  padding: 1.5rem 0;
  border-top: 1px solid var(--border);
}
.chart {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  padding: 1rem;
}
.chart__title {
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
  color: var(--text);
}
.chart__row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.375rem;
}
.chart__label {
  flex: 0 0 6rem;
  font-size: 0.75rem;
  text-align: right;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chart__bar-wrap {
  flex: 1;
  height: 1.125rem;
  background: var(--bg-alt);
  border-radius: 0.25rem;
  overflow: hidden;
}
.chart__bar {
  height: 100%;
  border-radius: 0.25rem;
  transition: width 0.4s ease-out;
  min-width: 2px;
}
.chart__value {
  flex: 0 0 1.75rem;
  font-size: 0.75rem;
  font-weight: 600;
  text-align: right;
  color: var(--text);
}

/* Timeline chart (vertical bars) */
.chart--timeline {
  overflow-x: auto;
}
.chart__bars-v {
  display: flex;
  align-items: flex-end;
  gap: 0.25rem;
  height: 7rem;
  padding-bottom: 1.5rem;
  position: relative;
  min-width: max-content;
}
.chart__bar-v {
  flex: 0 0 2rem;
  background: var(--accent);
  border-radius: 0.25rem 0.25rem 0 0;
  min-height: 3px;
  position: relative;
  transition: height 0.4s ease-out;
}
.chart__bar-v-label {
  position: absolute;
  bottom: -1.375rem;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.625rem;
  color: var(--text-muted);
  white-space: nowrap;
}
.chart__bar-v-value {
  position: absolute;
  top: -1rem;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.625rem;
  font-weight: 600;
  color: var(--text);
}

/* --- Responsive --- */
@media (max-width: 767px) {
  .kanban__column {
    min-width: 80vw;
  }
  .detail-panel {
    width: 100vw;
  }
  .stats__grid {
    gap: 0.375rem 0.75rem;
  }
  .stats__value {
    font-size: 1rem;
  }
  .stats__sep {
    display: none;
  }
  .filters__inner {
    gap: 0.375rem;
  }
  .nav__inner {
    flex-wrap: wrap;
  }
}

@media (min-width: 768px) {
  .charts {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1024px) {
  .kanban__column {
    flex: 1 1 0;
    min-width: 0;
  }
}

/* --- Reduced motion --- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
