/* ================================================================
   HUTCH CALL CENTER — TV DASHBOARD STYLES
   ----------------------------------------------------------------
   File layout:
   - Reset + CSS variables (colors used everywhere)
   - Page shell (body, background grid pattern, layout wrapper)
   - Header (logo, clock)
   - Top Agent cards (company-wide "most calls" / "most talk time")
   - Star of the Week strip (department-aware — CRM shows deposit
     counts, Retention shows LKR amounts)
   - Department switcher (CRM / Retention pills + 30s countdown bar)
   - Metrics row (5 summary cards, scoped to active department)
   - Agent performance table (splits into 2 columns for CRM,
     single column for Retention)
   - Footer
   - Department-rotation animation (fade + rise/scale effect)
   - Responsive breakpoints for tablet/phone
   ================================================================ */

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

:root {
  --orange: #FF6B2B;
  --gold: #FFB830;
  --bg: #0A0C10;
  --bg3: #181C24;
  --card: #161A22;
  --border: rgba(255,255,255,0.07);
  --text: #F0F2F8;
  --text-dim: #8A90A0;
  --text-dimmer: #4A5060;
  --green: #22C97A;
  --blue: #3B8EFF;
  --teal: #1DC8C8;
  --red: #FF4560;
  --purple: #C060FF;
}

/* ─── PAGE SHELL ─── */
body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* faint grid pattern behind everything, purely decorative */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(255,107,43,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,107,43,0.03) 1px, transparent 1px);
  background-size: 60px 60px;
  pointer-events: none;
  z-index: 0;
}

.everything {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  padding: 10px 16px 8px;
  gap: 8px;
}

/* ─── HEADER ─── */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.logo-area { display: flex; align-items: center; gap: 10px; }

.logo-badge {
  background: var(--orange);
  color: #fff;
  font-family: 'Bebas Neue', sans-serif;
  font-size: 16px;
  letter-spacing: 2px;
  padding: 3px 10px;
  border-radius: 4px;
}

.header-title {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 22px;
  letter-spacing: 3px;
}

.header-title span { color: var(--orange); }
.header-right { display: flex; align-items: center; gap: 14px; }

.live-badge {
  display: flex;
  align-items: center;
  gap: 5px;
  background: rgba(34,201,122,0.12);
  border: 1px solid rgba(34,201,122,0.3);
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 10px;
  font-weight: 500;
  color: var(--green);
  letter-spacing: 1px;
}

.live-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--green);
  animation: blink 1.2s ease-in-out infinite;
}

@keyframes blink { 0%,100%{opacity:1} 50%{opacity:0.2} }

.clock {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 22px;
  letter-spacing: 2px;
  color: var(--orange);
}

.date-label {
  font-size: 10px;
  color: var(--text-dim);
  text-align: right;
  letter-spacing: 1px;
}

/* ─── TOP AGENTS (company-wide, does not rotate) ─── */
.top-agents-strip {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  flex-shrink: 0;
}

.top-agent-card {
  background: var(--card);
  border: 1px solid rgba(255,184,48,0.3);
  border-radius: 8px;
  padding: 14px 22px;
  display: flex;
  align-items: center;
  gap: 18px;
  position: relative;
  overflow: hidden;
  background: linear-gradient(135deg, #1a1810 0%, var(--card) 60%);
}

.top-agent-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
}

.trophy-icon { font-size: 38px; flex-shrink: 0; }
.top-agent-info { flex: 1; min-width: 0; }

.top-agent-label {
  font-size: 12px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 4px;
}

.top-agent-name {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 26px;
  letter-spacing: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.top-agent-stat { font-size: 15px; color: var(--text-dim); margin-top: 2px; }
.top-agent-stat strong { color: var(--gold); }

.top-agent-value { text-align: right; flex-shrink: 0; }

.top-agent-number {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 48px;
  line-height: 1;
  color: var(--gold);
  text-shadow: 0 0 15px rgba(255,184,48,0.3);
}

.top-agent-unit { font-size: 12px; color: var(--text-dim); letter-spacing: 1px; }

/* ─── STAR OF THE WEEK (department-aware, rotates) ─── */
.sotw-strip {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 14px;
  flex-shrink: 0;
  background: linear-gradient(135deg, #1A1408 0%, #0F0D1A 100%);
  border: 1px solid rgba(255,184,48,0.25);
  border-radius: 8px;
  padding: 10px 16px;
  align-items: center;
  position: relative;
  overflow: hidden;
}

.sotw-strip::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, #FFB830, #FF6B2B, #FFB830, transparent);
}

.sotw-label-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding-right: 16px;
  border-right: 1px solid rgba(255,184,48,0.2);
  min-width: 100px;
}

.sotw-icon { font-size: 26px; }

.sotw-label {
  font-size: 10px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: #FFB830;
  font-weight: 600;
  text-align: center;
  line-height: 1.3;
}

.sotw-week {
  font-size: 9px;
  color: #4A5060;
  letter-spacing: 0.5px;
  text-align: center;
}

.sotw-agents {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
}

.sotw-agent {
  display: flex;
  align-items: center;
  gap: 18px;
  flex: 1;
  background: rgba(0,0,0,0.2);
  border-radius: 7px;
  padding: 8px 14px;
  border: 1px solid rgba(255,184,48,0.1);
}

.sotw-agent-rank {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 26px;
  line-height: 1;
  flex-shrink: 0;
}

.sotw-rank-1 { color: #FFB830; text-shadow: 0 0 10px rgba(255,184,48,0.4); }
.sotw-rank-2 { color: #94A3B8; }
.sotw-rank-3 { color: #CD8E50; }

.sotw-agent-info { flex: 1; min-width: 0; }

.sotw-agent-line {
  font-size: 17px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sotw-name-part {
  color: #F5F7FC;
}

.sotw-value-part {
  color: #FFB830;
  margin-left: 24px;
}

.sotw-medal { font-size: 20px; flex-shrink: 0; }

/* ─── DEPARTMENT SWITCHER ─── */
.dept-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.dept-pill-group {
  display: flex;
  gap: 6px;
}

.dept-pill {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 13px;
  letter-spacing: 2px;
  padding: 4px 16px;
  border-radius: 20px;
  border: 1px solid var(--border);
  color: var(--text-dimmer);
  background: var(--card);
  transition: all 0.4s ease;
  cursor: pointer;      /* signals it's clickable */
  user-select: none;
}

/* Inactive pill gets a subtle hover so it's obvious it can be clicked */
.dept-pill:not(.active):hover {
  color: var(--text);
  border-color: rgba(255,255,255,0.2);
  background: var(--bg3);
}

.dept-pill:active {
  transform: scale(0.96);
}

.dept-pill.active.crm {
  color: #fff;
  background: var(--orange);
  border-color: var(--orange);
  box-shadow: 0 0 14px rgba(255,107,43,0.4);
}

.dept-pill.active.retention {
  color: #fff;
  background: var(--purple);
  border-color: var(--purple);
  box-shadow: 0 0 14px rgba(192,96,255,0.4);
}

/* Wraps the "Next department in Xs" label + its countdown bar */
.dept-cycle-info {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 10px;
  color: var(--text-dim);
  letter-spacing: 0.5px;
}

/* 30s countdown bar showing time left before the next rotation */
.dept-cycle-track {
  width: 140px;
  height: 3px;
  background: var(--bg3);
  border-radius: 2px;
  overflow: hidden;
}

.dept-cycle-bar {
  height: 100%;
  border-radius: 2px;
  background: var(--gold);
  transform-origin: left;
  animation: deptcountdown 30s linear infinite;
}

@keyframes deptcountdown { from{transform:scaleX(1)} to{transform:scaleX(0)} }

/* ─── METRICS ─── */
.metrics-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  flex-shrink: 0;
}

.metric-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 12px;
  position: relative;
  overflow: hidden;
}

.metric-card::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 2px;
  border-radius: 0 0 8px 8px;
}

.metric-card.orange::after { background: var(--orange); }
.metric-card.green::after  { background: var(--green); }
.metric-card.blue::after   { background: var(--blue); }
.metric-card.teal::after   { background: var(--teal); }
.metric-card.red::after    { background: var(--red); }

.metric-label { font-size: 9px; color: var(--text-dim); letter-spacing: 1.5px; text-transform: uppercase; margin-bottom: 2px; }
.metric-value { font-family: 'Bebas Neue', sans-serif; font-size: 26px; line-height: 1; letter-spacing: 1px; }
.metric-card.orange .metric-value { color: var(--orange); }
.metric-card.green  .metric-value { color: var(--green); }
.metric-card.blue   .metric-value { color: var(--blue); }
.metric-card.teal   .metric-value { color: var(--teal); }
.metric-card.red    .metric-value { color: var(--red); }
.metric-sub { font-size: 9px; color: var(--text-dimmer); margin-top: 1px; }

/* ─── TABLE ─── */
.table-section {
  flex: 1;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.table-header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.table-title {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 14px;
  letter-spacing: 2px;
}

.table-title .dept-tag {
  font-size: 10px;
  padding: 1px 8px;
  border-radius: 10px;
  margin-left: 8px;
  letter-spacing: 1px;
  vertical-align: middle;
}
.table-title .dept-tag.crm { background: rgba(255,107,43,0.15); color: var(--orange); border: 1px solid rgba(255,107,43,0.3); }
.table-title .dept-tag.retention { background: rgba(192,96,255,0.15); color: var(--purple); border: 1px solid rgba(192,96,255,0.3); }

/* "Refresh in 60s" label + countdown bar next to it */
.refresh-info { font-size: 10px; color: var(--text-dim); display: flex; align-items: center; gap: 6px; }
.refresh-bar-wrap { width: 60px; height: 2px; background: var(--bg3); border-radius: 2px; overflow: hidden; }
.refresh-bar { height: 100%; background: var(--orange); border-radius: 2px; animation: countdown 60s linear forwards; transform-origin: left; }
@keyframes countdown { from{transform:scaleX(1)} to{transform:scaleX(0)} }

.table-columns {
  flex: 1;
  display: flex;
  min-height: 0;
  overflow: hidden;
}

.table-col {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.table-col + .table-col {
  border-left: 1px solid var(--border);
}

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

.data-table thead th {
  background: var(--bg3);
  color: var(--text-dim);
  font-size: 9px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  font-weight: 500;
  padding: 5px 6px;
  text-align: left;
  position: sticky;
  top: 0;
  z-index: 2;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  overflow: hidden;
}

.data-table thead th.right { text-align: right; }

.data-table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.2s;
}

.data-table tbody tr:hover { background: var(--bg3); }
.data-table tbody tr.highlight { background: rgba(255,184,48,0.04); }

.data-table tbody td {
  padding: 4px 12px;
  vertical-align: middle;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 12px;
  transition: font-size 0.2s ease;
}

/* ── Row size tiers ──────────────────────────────────────────
   script.js measures how much vertical space is available and
   applies one of these classes to each <tr> so text/avatars scale
   up to fill the box instead of leaving empty space below a short
   table (e.g. Retention's 8 rows on a tall TV). ── */
.data-table tbody tr.row-sm  td { font-size: 12px; }
.data-table tbody tr.row-md  td { font-size: 14px; }
.data-table tbody tr.row-lg  td { font-size: 16px; }
.data-table tbody tr.row-xl  td { font-size: 19px; }
.data-table tbody tr.row-xxl td { font-size: 22px; }
.data-table tbody tr.row-xxxl td { font-size: 25px; }

.data-table tbody tr.row-md   .agent-avatar { width: 21px; height: 21px; font-size: 9px; }
.data-table tbody tr.row-lg   .agent-avatar { width: 25px; height: 25px; font-size: 10px; }
.data-table tbody tr.row-xl   .agent-avatar { width: 32px; height: 32px; font-size: 12px; }
.data-table tbody tr.row-xxl  .agent-avatar { width: 38px; height: 38px; font-size: 14px; }
.data-table tbody tr.row-xxxl .agent-avatar { width: 44px; height: 44px; font-size: 17px; }

.data-table tbody tr.row-md   .agent-ext { font-size: 10px; }
.data-table tbody tr.row-lg   .agent-ext { font-size: 11px; }
.data-table tbody tr.row-xl   .agent-ext { font-size: 12px; }
.data-table tbody tr.row-xxl  .agent-ext { font-size: 14px; }
.data-table tbody tr.row-xxxl .agent-ext { font-size: 15px; }

.data-table tbody tr.row-md   .bar-label { font-size: 14px; }
.data-table tbody tr.row-lg   .bar-label { font-size: 17px; }
.data-table tbody tr.row-xl   .bar-label { font-size: 19px; }
.data-table tbody tr.row-xxl  .bar-label { font-size: 23px; }
.data-table tbody tr.row-xxxl .bar-label { font-size: 26px; }

.data-table tbody tr.row-md   .rank-badge { width: 17px; height: 17px; font-size: 9px; }
.data-table tbody tr.row-lg   .rank-badge { width: 20px; height: 20px; font-size: 10px; }
.data-table tbody tr.row-xl   .rank-badge { width: 24px; height: 24px; font-size: 12px; }
.data-table tbody tr.row-xxl  .rank-badge { width: 29px; height: 29px; font-size: 13px; }
.data-table tbody tr.row-xxxl .rank-badge { width: 33px; height: 33px; font-size: 15px; }

/* Ans % needs to fit "100%" (4 chars) so — like Talk Time — it grows
   more slowly than the rest of the row to avoid truncating with "…" */
/* In / Out / Ans In / Ans Out can occasionally reach 3 digits
   (e.g. Out = 219), so cap their growth slightly below the
   free-scaling columns (Agent name, rank, etc.) as a safety net. */
.data-table tbody tr.row-md   .num-right { font-size: 15px; }
.data-table tbody tr.row-lg   .num-right { font-size: 17px; }
.data-table tbody tr.row-xl   .num-right { font-size: 19px; }
.data-table tbody tr.row-xxl  .num-right { font-size: 22px; }
.data-table tbody tr.row-xxxl .num-right { font-size: 24px; }

/* Ans % also has class num-right, but needs its own (smaller) cap
   since "100%" has more characters — this must be declared AFTER
   the num-right block above so it wins (same CSS specificity, so
   source order decides). */
.data-table tbody tr.row-md   .pct-cell { font-size: 14px; }
.data-table tbody tr.row-lg   .pct-cell { font-size: 15px; }
.data-table tbody tr.row-xl   .pct-cell { font-size: 17px; }
.data-table tbody tr.row-xxl  .pct-cell { font-size: 19px; }
.data-table tbody tr.row-xxxl .pct-cell { font-size: 21px; }

.agent-cell { display: flex; align-items: center; gap: 6px; }

.agent-avatar {
  width: 22px; height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-weight: 600;
  flex-shrink: 0;
}

.agent-name { font-weight: 500; font-size: 12px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.agent-ext  { font-size: 9px; color: var(--text-dim); }

.rank-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px; height: 18px;
  border-radius: 50%;
  font-size: 9px;
  font-weight: 600;
}

.rank-1 { background: rgba(255,184,48,0.2); color: var(--gold); border: 1px solid rgba(255,184,48,0.4); }
.rank-2 { background: rgba(180,180,190,0.15); color: #C0C8D8; border: 1px solid rgba(180,180,190,0.3); }
.rank-3 { background: rgba(205,127,50,0.15); color: #CD8E50; border: 1px solid rgba(205,127,50,0.3); }
.rank-other { background: var(--bg3); color: var(--text-dim); border: 1px solid var(--border); }

.num-right { text-align: right; font-variant-numeric: tabular-nums; }

.bar-cell { padding: 4px 64px 4px 6px; text-align: left; }

.mini-bar-wrap { height: 3px; background: var(--bg3); border-radius: 2px; overflow: hidden; margin-top: 2px; }
.mini-bar { height: 100%; border-radius: 2px; background: var(--orange); }

.bar-label {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 13px;
  color: var(--orange);
}

.duration-cell { text-align: right; font-variant-numeric: tabular-nums; color: var(--teal); font-weight: 500; font-size: 12px; }

/* Talk Time shows 8 characters (HH:MM:SS) vs 2-4 digits elsewhere,
   so it needs to grow more slowly than the other columns to avoid
   getting clipped — these override the generic tr.row-* td rule
   above for just this one cell. */
.data-table tbody tr.row-md   .duration-cell { font-size: 13px; }
.data-table tbody tr.row-lg   .duration-cell { font-size: 15px; }
.data-table tbody tr.row-xl   .duration-cell { font-size: 17px; }
.data-table tbody tr.row-xxl  .duration-cell { font-size: 19px; }
.data-table tbody tr.row-xxxl .duration-cell { font-size: 21px; }
.answered-cell { color: var(--green); font-weight: 500; }
.pct-cell { font-weight: 600; }
.pct-good { color: var(--green); }
.pct-mid  { color: var(--gold); }
.pct-low  { color: var(--red); }

/* ─── FOOTER ─── */
footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  padding-top: 2px;
}

.footer-left  { font-size: 9px; color: var(--text-dimmer); letter-spacing: 1px; }
.footer-right { font-size: 9px; color: var(--text-dimmer); letter-spacing: 1px; }

/* ================================================================
   DEPARTMENT ROTATION ANIMATION
   ----------------------------------------------------------------
   #deptContent wraps everything that changes when CRM <-> Retention
   rotates: the Star of the Week strip, the department pills, the
   metrics row, and the agent table. script.js toggles the
   "fading" class briefly during a swap, which triggers this
   fade + gentle rise + scale transition. Feel free to tweak the
   timing/easing here without touching any JS.
   ================================================================ */
.dept-content {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
  flex: 1;
  transition: opacity 0.35s ease, transform 0.35s ease;
  opacity: 1;
  transform: translateY(0) scale(1);
}

.dept-content.fading {
  opacity: 0;
  transform: translateY(10px) scale(0.985);
}

/* ================================================================
   RESPONSIVE — tablet / phone
   The layout above is a fixed-height, no-scroll, wide TV format.
   Below ~900px we switch to a scrollable, stacked layout so it's
   usable on a phone or tablet browser too.
   ================================================================ */
@media (max-width: 900px) {
  body { height: auto; min-height: 100vh; overflow: visible; }
  .everything { height: auto; min-height: 100vh; padding: 8px 10px 10px; }

  header { flex-wrap: wrap; row-gap: 6px; }
  .header-title { font-size: 16px; letter-spacing: 1.5px; }
  .clock { font-size: 16px; }
  .date-label { font-size: 8px; }

  .top-agents-strip { grid-template-columns: 1fr; }
  .top-agent-number { font-size: 24px; }

  .sotw-strip { grid-template-columns: 1fr; padding: 8px 10px; }
  .sotw-label-wrap {
    flex-direction: row;
    justify-content: center;
    gap: 8px;
    border-right: none;
    border-bottom: 1px solid rgba(255,184,48,0.2);
    padding-right: 0;
    padding-bottom: 6px;
    min-width: 0;
  }
  .sotw-agents { flex-direction: column; gap: 6px; }
  .sotw-agent { width: 100%; }

  .dept-bar { flex-wrap: wrap; gap: 8px; }
  .dept-cycle-track { width: 100px; }

  .metrics-row { grid-template-columns: repeat(2, 1fr); }
  .metric-value { font-size: 20px; }

  .table-section { flex: none; overflow: visible; }
  .table-columns { flex-direction: column; overflow: visible; }
  .table-col + .table-col { border-left: none; border-top: 1px solid var(--border); }
  .data-table thead th { position: static; }
  .data-table thead th, .data-table tbody td { font-size: 11px; padding: 4px 5px; }
  .agent-name { font-size: 11px; }
  .agent-ext, .table-title { font-size: 9px; }

  footer { flex-wrap: wrap; gap: 4px; }
}

@media (max-width: 480px) {
  .header-title span { display: block; }
  .top-agent-card { flex-wrap: wrap; }
  .metrics-row { grid-template-columns: repeat(2, 1fr); gap: 6px; }
  .metric-value { font-size: 18px; }
  .data-table thead th:nth-child(2) { width: 100px !important; }
  .agent-avatar { width: 18px; height: 18px; font-size: 8px; }
}
