/* analytics.css — Panel Analytics de costes API · Design Pro */

/* ── Overlay ─────────────────────────────────────────────────── */
.an-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(6px);
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

/* ── Panel ───────────────────────────────────────────────────── */
.an-panel {
  width: min(960px, 100%);
  max-height: 88vh;
  background: #0f0f12;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 32px 80px rgba(0,0,0,0.7), 0 0 0 1px rgba(143,126,233,0.08);
}

/* ── Header ──────────────────────────────────────────────────── */
.an-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 14px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  gap: 12px;
  flex-shrink: 0;
}
.an-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
}
.an-header-icon { font-size: 18px; }
.an-header-title {
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.01em;
}
.an-header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Period tabs */
.an-period-tabs {
  display: flex;
  gap: 2px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 8px;
  padding: 3px;
}
.an-period-btn {
  font-size: 11px;
  font-weight: 600;
  color: rgba(255,255,255,0.45);
  background: transparent;
  border: none;
  border-radius: 5px;
  padding: 4px 10px;
  cursor: pointer;
  transition: all 150ms;
}
.an-period-btn:hover { color: rgba(255,255,255,0.75); }
.an-period-btn.is-active {
  background: rgba(143,126,233,0.2);
  color: #A78BFA;
}

.an-close-btn {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  border: 1px solid rgba(255,255,255,0.1);
  background: transparent;
  color: rgba(255,255,255,0.5);
  cursor: pointer;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 150ms;
}
.an-close-btn:hover { color: #fff; background: rgba(255,255,255,0.06); }

/* ── Nav tabs ─────────────────────────────────────────────────── */
.an-nav {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 0 20px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  flex-shrink: 0;
}
.an-nav-btn {
  font-size: 12px;
  font-weight: 600;
  color: rgba(255,255,255,0.4);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 10px 12px 9px;
  cursor: pointer;
  transition: all 150ms;
}
.an-nav-btn:hover { color: rgba(255,255,255,0.7); }
.an-nav-btn.is-active {
  color: #A78BFA;
  border-bottom-color: #A78BFA;
}
.an-nav-reload {
  margin-left: auto;
  font-size: 14px;
  color: rgba(255,255,255,0.3);
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 6px 8px;
  border-radius: 6px;
  transition: all 150ms;
}
.an-nav-reload:hover { color: #A78BFA; background: rgba(143,126,233,0.1); }

/* ── Body ────────────────────────────────────────────────────── */
.an-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.an-body::-webkit-scrollbar { width: 6px; }
.an-body::-webkit-scrollbar-track { background: transparent; }
.an-body::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; }

/* ── Alert banner ─────────────────────────────────────────────── */
.an-alert-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(239,68,68,0.12);
  border: 1px solid rgba(239,68,68,0.3);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 12px;
  color: #FCA5A5;
}
.an-alert-icon { font-size: 14px; }

/* ── Stats row ────────────────────────────────────────────────── */
.an-stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}
@media (max-width: 700px) {
  .an-stats-row { grid-template-columns: repeat(2, 1fr); }
}
.an-stat-card {
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 10px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.an-stat-label { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em; color: rgba(255,255,255,0.35); }
.an-stat-value { font-size: 22px; font-weight: 800; color: rgba(255,255,255,0.9); letter-spacing: -0.02em; }
.an-stat-sub { font-size: 10px; color: rgba(255,255,255,0.3); }

/* ── Limit bar ─────────────────────────────────────────────────── */
.an-limit-bar-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.an-limit-bar-label {
  display: flex;
  justify-content: space-between;
  font-size: 10.5px;
  color: rgba(255,255,255,0.45);
}
.an-limit-bar {
  height: 5px;
  background: rgba(255,255,255,0.06);
  border-radius: 99px;
  overflow: hidden;
}
.an-limit-fill {
  height: 100%;
  background: linear-gradient(90deg, #8F7EE9, #A78BFA);
  border-radius: 99px;
  transition: width 600ms ease;
}
.an-limit-fill.danger {
  background: linear-gradient(90deg, #EF4444, #F97316);
}

/* ── Section ─────────────────────────────────────────────────── */
.an-section { display: flex; flex-direction: column; gap: 10px; }
.an-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: rgba(255,255,255,0.3);
}

/* ── Provider cards ───────────────────────────────────────────── */
.an-provider-row { display: flex; gap: 10px; flex-wrap: wrap; }
.an-provider-card {
  flex: 1;
  min-width: 140px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 10px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.an-provider-card.claude { border-color: rgba(143,126,233,0.25); }
.an-provider-card.kidai { border-color: rgba(34,197,94,0.2); }
.an-provider-name { font-size: 12px; font-weight: 600; color: rgba(255,255,255,0.7); }
.an-provider-cost { font-size: 20px; font-weight: 800; color: #A78BFA; letter-spacing: -0.02em; }
.an-provider-card.kidai .an-provider-cost { color: #4ADE80; }
.an-provider-calls { font-size: 10px; color: rgba(255,255,255,0.35); }

/* ── Tables ───────────────────────────────────────────────────── */
.an-table-wrap { overflow-x: auto; border-radius: 8px; border: 1px solid rgba(255,255,255,0.07); }
.an-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.an-table th {
  font-size: 9.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: rgba(255,255,255,0.3);
  background: rgba(255,255,255,0.02);
  padding: 9px 12px;
  text-align: left;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.an-table td {
  padding: 9px 12px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  color: rgba(255,255,255,0.75);
  vertical-align: middle;
}
.an-table tr:last-child td { border-bottom: none; }
.an-table tr:hover td { background: rgba(255,255,255,0.02); }
.an-table-sm td, .an-table-sm th { padding: 7px 10px; font-size: 11px; }
.an-table.an-table-sm th { font-size: 9px; }

.an-num { text-align: right; font-variant-numeric: tabular-nums; }
.an-cost { color: #A78BFA !important; font-weight: 600; }
.an-muted { color: rgba(255,255,255,0.35) !important; font-size: 11px; }
.an-date { font-size: 10.5px; color: rgba(255,255,255,0.4); white-space: nowrap; }
.an-empty { text-align: center; color: rgba(255,255,255,0.25); padding: 24px; font-size: 12px; }
.an-row-error td { background: rgba(239,68,68,0.05) !important; }

/* badges */
.an-model-badge {
  font-size: 10px;
  font-family: monospace;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 4px;
  padding: 2px 6px;
  color: rgba(255,255,255,0.7);
  white-space: nowrap;
}
.an-model-badge.sm { font-size: 9px; padding: 1px 5px; }
.an-provider {
  font-size: 9.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 2px 6px;
  border-radius: 4px;
}
.an-provider.claude { color: #A78BFA; background: rgba(143,126,233,0.12); }
.an-provider.kidai  { color: #4ADE80; background: rgba(34,197,94,0.1); }
.an-status {
  font-size: 9.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 2px 6px;
  border-radius: 4px;
}
.an-status.ok    { color: #4ADE80; background: rgba(34,197,94,0.1); }
.an-status.error { color: #F87171; background: rgba(239,68,68,0.1); }

/* ── History ─────────────────────────────────────────────────── */
.an-history { display: flex; flex-direction: column; gap: 12px; }
.an-filter-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}
.an-input {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 7px;
  color: rgba(255,255,255,0.8);
  font-size: 12px;
  padding: 7px 10px;
  outline: none;
  transition: border-color 150ms;
}
.an-input:focus { border-color: rgba(143,126,233,0.5); }
.an-input.sm { padding: 5px 8px; font-size: 11px; width: 80px; }
.an-history-meta { font-size: 11px; color: rgba(255,255,255,0.3); }
.an-spin { animation: blink 1s infinite; }
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:0} }

/* ── Pricing ─────────────────────────────────────────────────── */
.an-pricing { display: flex; flex-direction: column; gap: 12px; }
.an-pricing-note { font-size: 11px; color: rgba(255,255,255,0.35); margin: 0; line-height: 1.5; }
.an-price-input {
  width: 90px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 6px;
  color: rgba(255,255,255,0.8);
  font-size: 11px;
  padding: 5px 7px;
  outline: none;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.an-price-input:focus { border-color: rgba(143,126,233,0.5); }

/* ── Alerts ──────────────────────────────────────────────────── */
.an-alerts { display: flex; flex-direction: column; gap: 12px; }
.an-alert-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 10px;
  padding: 14px 16px;
}
.an-alert-period {
  font-size: 13px;
  font-weight: 700;
  color: rgba(255,255,255,0.7);
  min-width: 70px;
}
.an-alert-label { font-size: 11px; color: rgba(255,255,255,0.4); }
.an-alert-currency { font-size: 12px; color: rgba(255,255,255,0.5); }

/* Toggle */
.an-toggle { position: relative; display: inline-flex; cursor: pointer; }
.an-toggle input { opacity: 0; width: 0; height: 0; position: absolute; }
.an-toggle-track {
  width: 34px;
  height: 18px;
  background: rgba(255,255,255,0.1);
  border-radius: 99px;
  transition: background 200ms;
  position: relative;
}
.an-toggle-track::after {
  content: "";
  position: absolute;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #fff;
  top: 3px;
  left: 3px;
  transition: transform 200ms;
}
.an-toggle input:checked + .an-toggle-track { background: #8F7EE9; }
.an-toggle input:checked + .an-toggle-track::after { transform: translateX(16px); }

/* ── Buttons ─────────────────────────────────────────────────── */
.an-btn {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 7px;
  color: rgba(255,255,255,0.7);
  font-size: 12px;
  font-weight: 600;
  padding: 7px 14px;
  cursor: pointer;
  transition: all 150ms;
}
.an-btn:hover { background: rgba(255,255,255,0.1); color: #fff; }
.an-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.an-btn.sm { font-size: 11px; padding: 5px 10px; }
.an-btn.accent {
  background: rgba(143,126,233,0.15);
  border-color: rgba(143,126,233,0.3);
  color: #A78BFA;
}
.an-btn.accent:hover { background: rgba(143,126,233,0.25); }

/* ── Pagination ──────────────────────────────────────────────── */
.an-pagination {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 11px;
  color: rgba(255,255,255,0.4);
  justify-content: center;
  padding-top: 4px;
}

/* ── States ──────────────────────────────────────────────────── */
.an-loading {
  text-align: center;
  color: rgba(255,255,255,0.3);
  font-size: 12px;
  padding: 32px;
}
.an-error {
  background: rgba(239,68,68,0.08);
  border: 1px solid rgba(239,68,68,0.2);
  border-radius: 8px;
  padding: 14px 16px;
  font-size: 12px;
  color: #FCA5A5;
  line-height: 1.6;
}
.an-error small { color: rgba(252,165,165,0.6); }
.an-toast {
  background: rgba(74,222,128,0.12);
  border: 1px solid rgba(74,222,128,0.25);
  border-radius: 7px;
  padding: 8px 14px;
  font-size: 11.5px;
  color: #4ADE80;
  font-weight: 600;
}
