/* ============================================================
   Power BI Status Dashboard — Level Up Design System (CRM Dark)
   Airport board layout — 3 panels by status
   Brand: #6A329F (purple) + #F98727 (orange)
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* ---- CSS custom properties ------------------------------- */

:root {
  --bg:           hsl(222, 47%, 6%);
  --bg-card:      hsl(222, 47%, 9%);
  --bg-secondary: hsl(222, 47%, 12%);
  --bg-muted:     hsl(222, 47%, 14%);
  --border:       hsl(222, 47%, 18%);
  --text:         hsl(210, 40%, 96%);
  --text-muted:   hsl(215, 20%, 55%);
  --text-subtle:  hsl(215, 20%, 38%);
  --purple:       #6A329F;
  --purple-light: #8B4FBE;
  --purple-dim:   rgba(106, 50, 159, 0.20);
  --orange:       #F98727;
  --orange-dim:   rgba(249, 135, 39, 0.20);
  --green:        hsl(142, 70%, 45%);
  --green-dim:    hsla(142, 70%, 45%, 0.12);
  --yellow:       hsl(45, 100%, 51%);
  --red:          hsl(0, 80%, 58%);
  --red-dim:      hsla(0, 80%, 58%, 0.12);
  --blue:         hsl(210, 80%, 60%);
  --blue-dim:     hsla(210, 80%, 60%, 0.12);
  --font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

/* ---- 1. Reset + base ------------------------------------- */

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-family);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* ---- 2. Navbar ------------------------------------------- */

.navbar {
  background: hsl(222, 47%, 5%);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.25rem;
  height: 52px;
  flex-shrink: 0;
  box-shadow: 0 2px 16px rgba(0, 0, 0, 0.4);
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
}

.navbar-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.filter-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.workspace-select {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 0.78rem;
  font-family: var(--font-family);
  cursor: pointer;
  max-width: 200px;
  outline: none;
}

.workspace-select:focus {
  border-color: var(--purple-light);
}

.last-updated {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.pulse-dot {
  width: 8px;
  height: 8px;
  background: var(--orange);
  border-radius: 50%;
  animation: pulse-dot 2s infinite;
  box-shadow: 0 0 8px rgba(249, 135, 39, 0.6);
  flex-shrink: 0;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.7; transform: scale(1.4); }
}

/* ---- 3. Status banner ------------------------------------ */

.status-banner {
  display: none;
  padding: 0.45rem 1.25rem;
  font-size: 0.82rem;
  border-bottom: 1px solid transparent;
  flex-shrink: 0;
}

.status-banner.visible {
  display: block;
  background: var(--red-dim);
  border-bottom-color: var(--red);
  color: hsl(0, 80%, 75%);
}

.status-banner.starting {
  display: block;
  background: var(--blue-dim);
  border-bottom-color: var(--blue);
  color: hsl(210, 80%, 75%);
}

/* ---- 4. Stats bar ---------------------------------------- */

.stats-bar {
  background: hsl(222, 47%, 7%);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  padding: 0.6rem 1.25rem 0.65rem;
}

/* Proportional RGB bar */
.health-bar-track {
  display: flex;
  height: 4px;
  border-radius: 2px;
  overflow: hidden;
  background: var(--bg-secondary);
  margin-bottom: 0.65rem;
}

.health-bar-seg {
  transition: width 0.5s ease;
}

.health-bar-ok     { background: var(--green); }
.health-bar-failed { background: var(--red); }
.health-bar-nodata { background: var(--text-subtle); }

/* Scorecard row */
.stats-cards {
  display: flex;
  gap: 0;
}

.stat-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 0 1.1rem;
  border-right: 1px solid var(--border);
  min-width: 0;
}

.stat-card:first-child { padding-left: 0; }
.stat-card:last-child  { border-right: none; }

.stat-value {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stat-label {
  font-size: 0.67rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-top: 2px;
  white-space: nowrap;
}

.stat-pct {
  color: var(--text-subtle);
  font-size: 0.67rem;
}

.stat-sub {
  font-size: 0.72rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
}

/* Card color variants */
.stat-card--ok     .stat-value { color: var(--green); }
.stat-card--failed .stat-value { color: var(--red); }
.stat-card--nodata .stat-value { color: var(--text-muted); }

/* Oldest OK — default muted, warning/danger by JS class */
.stat-card--oldest .stat-value          { font-size: 1rem; color: var(--text-muted); }
.stat-card--oldest .stat-value--warn    { color: var(--orange); }
.stat-card--oldest .stat-value--danger  { color: var(--red); }

/* Stats responsive */
@media (max-width: 900px) {
  .stats-cards {
    flex-wrap: wrap;
    gap: 0.5rem 0;
  }
  .stat-card {
    flex: 1 1 33%;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 0.3rem 0.75rem;
  }
}

@media (max-width: 640px) {
  .stat-card { flex: 1 1 50%; }
  .stat-card--oldest { flex: 1 1 100%; }
}

/* ---- 5. Board container — 3 columns ---------------------- */

.board-container {
  flex: 1;
  display: flex;
  flex-direction: row;
  overflow: hidden;
  min-height: 0;
}

/* ---- 5. Board panel -------------------------------------- */

.board-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  min-width: 0;
  min-height: 0;
}

.board-panel:last-child {
  border-right: none;
}

/* ---- 6. Panel header ------------------------------------- */

.board-header {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.65rem 1rem;
  border-bottom: 2px solid transparent;
  flex-shrink: 0;
}

.board-panel--failed .board-header {
  background: var(--red-dim);
  border-bottom-color: var(--red);
}
.board-panel--active .board-header {
  background: var(--blue-dim);
  border-bottom-color: var(--blue);
}
.board-panel--completed .board-header {
  background: var(--green-dim);
  border-bottom-color: var(--green);
}

.board-icon {
  font-size: 1rem;
  font-weight: 700;
  line-height: 1;
}
.board-panel--failed   .board-icon { color: var(--red); }
.board-panel--active   .board-icon { color: var(--blue); }
.board-panel--completed .board-icon { color: var(--green); }

@keyframes spin {
  from { display: inline-block; transform: rotate(0deg); }
  to   { display: inline-block; transform: rotate(360deg); }
}
.board-icon--spin {
  display: inline-block;
  animation: spin 2s linear infinite;
}

.board-title {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.board-panel--failed   .board-title { color: var(--red); }
.board-panel--active   .board-title { color: var(--blue); }
.board-panel--completed .board-title { color: var(--green); }

.board-count {
  margin-left: auto;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 1px 9px;
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 600;
  min-width: 28px;
  text-align: center;
}

/* ---- 7. Panel body (scrollable) -------------------------- */

.board-body {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

.board-empty {
  padding: 2.5rem 1rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* ---- 8. Board table -------------------------------------- */

.board-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.board-table col.col-dataset    { width: 50%; }
.board-table col.col-refresh    { width: 26%; }
.board-table col.col-duration   { width: 10%; }
.board-table col.col-history    { width: 14%; }

.board-table thead th {
  padding: 0.5rem 0.75rem;
  font-size: 0.67rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  font-weight: 600;
  text-align: left;
  background: var(--bg-secondary);
  position: sticky;
  top: 0;
  z-index: 2;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.th-sortable {
  cursor: pointer;
  user-select: none;
}

.th-sortable:hover {
  color: var(--text);
  background: var(--bg-muted);
}

.th-sort-active {
  color: var(--purple-light);
}

.sort-ind {
  margin-left: 4px;
  font-size: 0.58rem;
  opacity: 0.6;
}

.th-sort-active .sort-ind {
  opacity: 1;
  color: var(--purple-light);
}

.board-table tbody td {
  padding: 0.45rem 0.75rem;
  font-size: 0.8rem;
  border-top: 1px solid var(--border);
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.col-dataset-cell {
  /* hosts both ds-name and ds-workspace stacked */
}

.ds-name {
  display: block;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ds-workspace {
  display: block;
  font-size: 0.7rem;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-top: 1px;
  line-height: 1.3;
}

.col-refresh-cell,
.col-duration-cell {
  color: var(--text-muted);
}

/* ---- 9. EN PROCESO collapsed state ----------------------- */

.board-panel--collapsed {
  flex: 0 0 48px;
  min-width: 48px;
}

.board-panel--collapsed .board-header {
  flex-direction: column;
  height: 100%;
  padding: 0.75rem 0.25rem;
  gap: 0.6rem;
  align-items: center;
  justify-content: flex-start;
  border-bottom: none;
  overflow: hidden;
}

.board-panel--collapsed .board-icon--spin {
  margin-top: 0.25rem;
}

.board-panel--collapsed .board-title {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  letter-spacing: 0.12em;
  font-size: 0.65rem;
}

.board-panel--collapsed .board-count {
  margin: 0;
}

.board-panel--collapsed .board-body {
  display: none;
}

/* On mobile the collapsed panel becomes a compact horizontal strip */
@media (max-width: 900px) {
  .board-panel--collapsed {
    flex: 0 0 auto;
    min-width: 0;
    max-height: 44px;
  }
  .board-panel--collapsed .board-header {
    flex-direction: row;
    height: auto;
    padding: 0.65rem 1rem;
  }
  .board-panel--collapsed .board-title {
    writing-mode: horizontal-tb;
    transform: none;
  }
  .board-panel--collapsed .board-count {
    margin-left: auto;
  }
}

/* ---- 10. Separator row (nodata section in completed) ------ */

.board-separator td {
  padding: 0.35rem 0.75rem;
  font-size: 0.67rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-subtle);
  background: hsl(222, 47%, 10%);
  border-top: 1px solid var(--border);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.board-row--nodata td {
  opacity: 0.45;
}

/* ---- 10. History dots ------------------------------------ */

.history-dots {
  display: flex;
  gap: 4px;
  align-items: center;
}

.dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.dot-completed { background: var(--green); }
.dot-failed    { background: var(--red); }
.dot-unknown   { background: var(--text-subtle); }

/* ---- 11. Scrollbar --------------------------------------- */

::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--bg-muted); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: hsl(222, 47%, 25%); }

/* ---- 12. Responsive ------------------------------------- */

@media (max-width: 1100px) {
  .board-table col.col-dataset  { width: 52%; }
  .board-table col.col-refresh  { width: 26%; }
  .board-table col.col-duration { width: 10%; }
  .board-table col.col-history  { width: 12%; }
}

@media (max-width: 900px) {
  body {
    height: auto;
    overflow: auto;
  }
  .board-container {
    flex-direction: column;
    overflow: visible;
  }
  .board-panel {
    border-right: none;
    border-bottom: 1px solid var(--border);
    max-height: 45vh;
    min-height: 180px;
  }
  .board-panel:last-child {
    border-bottom: none;
  }
}

@media (max-width: 640px) {
  /* Hide duration column on mobile (3rd col: Dataset, Refresh, Dur, Hist) */
  .board-table col.col-duration,
  .board-table thead th:nth-child(3),
  .board-table tbody td:nth-child(3) {
    display: none;
  }
  .filter-label {
    display: none;
  }
  .workspace-select {
    max-width: 130px;
  }
}
