/* ═══════════════════════════════════════════════════
   LYRA CLAUDE USAGE — Lyra Branding Theme v4
   ═══════════════════════════════════════════════════ */

:root {
  --bg: #0c0c14;
  --surface: #12121e;
  --card: #1a1a2e;
  --card-hover: #1f1f38;
  --border: #2a2a45;
  --border-subtle: #1e1e35;
  --text-primary: #ededf4;
  --text-secondary: #9494b0;
  --text-dim: #5e5e78;
  --accent: #8442ff;
  --accent-bright: #695fff;
  --accent-blue: #1969ff;
  --accent-dim: #6d3fd4;
  --accent-glow: rgba(132, 66, 255, 0.25);
  --green: #10b981;
  --green-glow: rgba(16, 185, 129, 0.2);
  --red: #ef4444;
  --red-glow: rgba(239, 68, 68, 0.2);
  --progress-low: #10b981;
  --progress-medium: #f59e0b;
  --progress-high: #ef4444;
  --mono: "JetBrains Mono", "SF Mono", "Fira Code", Menlo, Consolas, monospace;
  --sans: "Satoshi", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
}

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

html {
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
}

/* Dot grid overlay */
.dot-grid {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image: radial-gradient(circle at 1px 1px, rgba(255, 255, 255, 0.022) 1px, transparent 0);
  background-size: 40px 40px;
}

/* ─── Login ─── */

.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-box {
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  width: 260px;
}

.login-box h2 {
  font-family: var(--sans);
  font-weight: 500;
  font-size: 1.3rem;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

.login-box input {
  font-family: var(--mono);
  font-size: 0.8rem;
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text-primary);
  outline: none;
  text-align: center;
}

.login-box input:focus {
  border-color: var(--accent);
}

.login-box button {
  font-family: var(--mono);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--card);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
}

.login-box button:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-glow);
}

.login-error {
  font-family: var(--mono);
  font-size: 0.65rem;
  color: var(--red);
  min-height: 1rem;
}

/* ─── Header ─── */

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.2rem 2rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.logo svg {
  display: block;
}

.header-title h1 {
  font-family: var(--sans);
  font-size: 1.4rem;
  font-weight: 500;
  letter-spacing: -0.3px;
  color: var(--text-primary);
  line-height: 1;
}

/* ─── Tabs ─── */

.tabs {
  display: flex;
  gap: 0.25rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 3px;
}

.tab {
  font-family: var(--mono);
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0.35rem 0.9rem;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.15s;
}

.tab:hover {
  color: var(--text-secondary);
}

.tab.active {
  background: var(--accent);
  color: #fff;
}

/* ─── Column Header Average ─── */

.col-avg {
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.02em;
}

/* ─── Main ─── */

main {
  max-width: 1080px;
  margin: 0 auto;
  padding: 1.5rem 2rem 4rem;
  position: relative;
  z-index: 1;
}

/* ─── Tab Content ─── */

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* ─── Table ─── */

.table-container {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  animation: fadeUp 0.5s cubic-bezier(0.4, 0, 0.2, 1) both;
  animation-delay: 0.1s;
}

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

.usage-table th {
  font-family: var(--mono);
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 0.15em;
  color: var(--text-dim);
  text-transform: uppercase;
  text-align: left;
  padding: 0.9rem 1.2rem;
  border-bottom: 1px solid var(--border);
  background: var(--card);
}

.col-name { width: 28%; }
.col-usage { width: 32%; }
.col-status { width: 8%; text-align: center; }

.usage-table td {
  font-family: var(--sans);
  font-size: 0.85rem;
  padding: 1rem 1.2rem;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
  vertical-align: middle;
}

.usage-table tbody tr.data-row {
  transition: background 0.15s;
}

.usage-table tbody tr.data-row:hover {
  background: var(--card-hover);
}

.usage-table tbody tr.data-row:last-child td {
  border-bottom: none;
}

/* ─── Name cell ─── */

.td-name {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.td-name .display-name {
  color: var(--text-primary);
  font-weight: 600;
  font-size: 0.85rem;
}

.td-name .email-sub {
  font-size: 0.7rem;
  color: var(--text-dim);
}

.row-index {
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--text-dim);
  margin-right: 0.15rem;
}

.employee-sub {
  font-size: 0.7rem;
  color: var(--text-secondary);
}

.stats-sub {
  font-size: 0.65rem;
  color: var(--text-dim);
  font-family: var(--mono);
}

/* ─── Progress bar ─── */

.progress-cell {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.progress-label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-family: var(--mono);
  font-size: 0.7rem;
}

.progress-count {
  font-weight: 700;
  color: var(--text-primary);
}

.progress-pct {
  font-size: 0.6rem;
  color: var(--text-dim);
}

.progress-track {
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: var(--card);
  overflow: hidden;
  position: relative;
}

.progress-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  background: linear-gradient(90deg, var(--accent), var(--accent-blue));
}

.progress-fill.low {
  background: linear-gradient(90deg, var(--progress-low), #34d399);
}

.progress-fill.medium {
  background: linear-gradient(90deg, var(--progress-medium), #fbbf24);
}

.progress-fill.high {
  background: linear-gradient(90deg, var(--progress-high), #f87171);
}

.progress-reset {
  font-family: var(--mono);
  font-size: 0.55rem;
  color: var(--text-dim);
}

/* ─── Status ─── */

.td-status {
  text-align: center;
}

.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  position: relative;
}

.status-dot.online {
  background: var(--green);
  box-shadow: 0 0 6px var(--green-glow);
}

.status-dot.online::after {
  content: "";
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  border: 1px solid var(--green);
  opacity: 0.3;
  animation: pulse-ring 2s ease-out infinite;
}

.status-dot.offline {
  background: var(--red);
  box-shadow: 0 0 6px var(--red-glow);
}

.status-dot.error {
  background: var(--red);
  box-shadow: 0 0 6px var(--red-glow);
}

.status-dot.warning {
  background: var(--amber);
}

.status-dot.throttled {
  background: var(--red);
  box-shadow: 0 0 6px var(--red-glow);
}

.no-data {
  color: var(--text-dim);
  font-style: italic;
}

@keyframes pulse-ring {
  0% { transform: scale(1); opacity: 0.3; }
  100% { transform: scale(2); opacity: 0; }
}

/* ─── Range buttons (History tab) ─── */

.range-buttons {
  display: flex;
  gap: 0.25rem;
  margin-bottom: 1rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 3px;
  width: fit-content;
}

.range-btn {
  font-family: var(--mono);
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0.3rem 0.7rem;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.15s;
}

.range-btn:hover {
  color: var(--text-secondary);
}

.range-btn.active {
  background: var(--accent);
  color: #fff;
}

/* ─── Chart ─── */

.chart-section {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.chart-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem;
  animation: fadeUp 0.5s cubic-bezier(0.4, 0, 0.2, 1) both;
}

.chart-title {
  font-family: var(--mono);
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 1rem;
}

.chart-wrap {
  position: relative;
  height: 320px;
}

.chart-loading {
  text-align: center;
  padding: 3rem;
  display: none;
}

/* ─── Loading ─── */

.loading-row td {
  text-align: center;
  padding: 3rem 1rem !important;
}

.loading-pulse {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--text-dim);
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--text-dim);
}

/* ─── Footer ─── */

footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 2rem;
  font-family: var(--mono);
  font-size: 0.6rem;
  color: var(--text-dim);
  background: var(--surface);
  border-top: 1px solid var(--border);
  z-index: 100;
}

/* ─── Animations ─── */

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

tr.data-row {
  animation: fadeIn 0.3s ease both;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ─── Responsive: Tablet ─── */

@media (max-width: 768px) {
  main {
    padding: 1rem;
  }

  header {
    padding: 0.9rem 1rem;
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .header-title h1 {
    font-size: 1.15rem;
  }

  .usage-table th,
  .usage-table td {
    padding: 0.7rem 0.6rem;
  }

  .col-name { width: 30%; }
  .col-usage { width: 30%; }
  .col-status { width: 10%; }

  footer {
    padding: 0.5rem 1rem;
  }

  .footer-right {
    display: none;
  }

  .chart-wrap {
    height: 240px;
  }
}

/* ─── Responsive: Mobile — cards ─── */

@media (max-width: 600px) {
  main {
    padding: 0.75rem;
    padding-bottom: 3.5rem;
  }

  header {
    padding: 0.75rem 1rem;
  }

  .logo svg {
    width: 26px;
    height: 26px;
  }

  .header-title h1 {
    font-size: 1.05rem;
  }

  .tabs {
    order: 3;
    width: 100%;
    justify-content: center;
  }

  .table-container {
    background: transparent;
    border: none;
    border-radius: 0;
  }

  .usage-table {
    table-layout: auto;
  }

  /* Hide the thead */
  .usage-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
  }

  /* Make table elements block-level */
  .usage-table,
  .usage-table tbody,
  .usage-table tr.data-row,
  .usage-table td {
    display: block;
    width: 100%;
  }

  /* Each row = a card */
  .usage-table tbody tr.data-row {
    position: relative;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    margin-bottom: 0.6rem;
    padding: 0;
    overflow: hidden;
  }

  .usage-table tbody tr.data-row:hover {
    background: var(--surface);
  }

  /* Remove td borders inside cards */
  .usage-table td {
    border-bottom: none;
    padding: 0.6rem 0.85rem;
  }

  /* Name cell: top of card with status dot */
  .usage-table td:first-child {
    padding-bottom: 0.25rem;
    padding-right: 2.5rem;
  }

  .td-name .display-name {
    font-size: 0.9rem;
  }

  /* Status dot: float to top-right of card */
  .usage-table td:last-child {
    position: absolute;
    top: 0.75rem;
    right: 0.85rem;
    width: auto;
    padding: 0;
  }

  /* Progress cells: compact within card */
  .usage-table td:nth-child(2),
  .usage-table td:nth-child(3) {
    padding-top: 0.15rem;
    padding-bottom: 0.15rem;
  }

  /* Add subtle label before each progress bar */
  .usage-table td:nth-child(2) .progress-cell::before,
  .usage-table td:nth-child(3) .progress-cell::before {
    font-family: var(--mono);
    font-size: 0.5rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-dim);
    margin-bottom: 0.15rem;
    display: block;
  }

  .usage-table td:nth-child(2) .progress-cell::before {
    content: "SESSION";
  }

  .usage-table td:nth-child(3) .progress-cell::before {
    content: "WEEK";
  }

  /* Last td in card gets bottom padding */
  .usage-table td:nth-child(3) {
    padding-bottom: 0.7rem;
  }

  .progress-label {
    font-size: 0.65rem;
  }

  .progress-track {
    height: 5px;
  }

  .chart-wrap {
    height: 200px;
  }

  /* Footer: compact */
  footer {
    padding: 0.4rem 0.75rem;
    font-size: 0.5rem;
    gap: 0.5rem;
  }

  .footer-right {
    display: none;
  }
}
