/* ═══════════════════════════════════════════════════════════════
   Alpvis RMS v2 — Design System Components
   Light Mode Standard. Works with existing style.css + premium.
   ═══════════════════════════════════════════════════════════════ */

/* ─── V2 KPI CARDS ────────────────────────────────────────── */

.v2-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.v2-kpi {
  background: var(--p-surface, #fff);
  border: 1px solid var(--p-border, #e5e8ef);
  border-radius: var(--p-radius-md, 10px);
  padding: 16px;
  transition: var(--p-transition, 0.18s ease);
}
.v2-kpi:hover { box-shadow: var(--p-shadow-sm); }
.v2-kpi[onclick] { cursor: pointer; }
.v2-kpi-icon { font-size: 20px; margin-bottom: 4px; }
.v2-kpi-label { font-size: 11px; color: var(--p-text-muted, #9298ad); text-transform: uppercase; letter-spacing: 0.04em; font-weight: 500; }
.v2-kpi-value { font-size: 28px; font-weight: 700; margin-top: 4px; line-height: 1.1; }
.v2-kpi-sub { font-size: 11px; color: var(--p-text-secondary, #5b6178); margin-top: 4px; }

/* ─── V2 BADGES ───────────────────────────────────────────── */

.v2-badge { display: inline-flex; align-items: center; gap: 3px; padding: 2px 8px; border-radius: 3px; font-size: 11px; font-weight: 600; line-height: 1.4; white-space: nowrap; }
.v2-badge-xs { display: inline-flex; padding: 1px 6px; border-radius: 3px; font-size: 9px; font-weight: 600; color: var(--p-text-muted); background: var(--p-bg-alt, #f1f3f8); }

/* ─── V2 CARDS ────────────────────────────────────────────── */

.v2-card { background: var(--p-surface, #fff); border: 1px solid var(--p-border, #e5e8ef); border-radius: var(--p-radius-md, 10px); padding: 14px; margin-bottom: 8px; transition: var(--p-transition); }
.v2-card:hover { box-shadow: var(--p-shadow-xs); }
.v2-card-border { border-left: 3px solid #6b7280; }
.v2-card-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.v2-card-main { flex: 1; min-width: 0; }
.v2-card-header { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-bottom: 4px; }
.v2-card-icon { font-size: 16px; }
.v2-card-title { font-size: 13px; font-weight: 700; }
.v2-card-desc { font-size: 12px; color: var(--p-text-secondary, #5b6178); line-height: 1.5; }
.v2-actions { display: flex; gap: 4px; flex-shrink: 0; }

/* ─── V2 BUTTONS ──────────────────────────────────────────── */

.v2-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 16px; border-radius: var(--p-radius-sm, 6px); font-size: 13px; font-weight: 600; border: none; cursor: pointer; transition: var(--p-transition); font-family: inherit; }
.v2-btn-sm { padding: 4px 10px; font-size: 12px; }
.v2-btn-primary { background: var(--p-primary, #3366ff); color: #fff; }
.v2-btn-primary:hover { background: var(--p-primary-hover, #2952cc); }
.v2-btn-secondary { background: var(--p-primary-soft, rgba(51,102,255,0.08)); color: var(--p-primary, #3366ff); }
.v2-btn-secondary:hover { background: rgba(51,102,255,0.15); }
.v2-btn-ghost { background: transparent; color: var(--p-text-secondary, #5b6178); }
.v2-btn-ghost:hover { background: var(--p-bg-alt, #f1f3f8); }

/* ─── V2 TABS ─────────────────────────────────────────────── */

.v2-tabs { display: flex; gap: 4px; margin-bottom: 16px; flex-wrap: wrap; }
.v2-tab { padding: 6px 14px; border-radius: var(--p-radius-sm, 6px); font-size: 13px; font-weight: 500; border: none; cursor: pointer; background: transparent; color: var(--p-text-secondary, #5b6178); transition: var(--p-transition); font-family: inherit; }
.v2-tab:hover { background: var(--p-bg-alt, #f1f3f8); }
.v2-tab-active { background: var(--p-primary, #3366ff); color: #fff; }
.v2-tab-active:hover { background: var(--p-primary-hover, #2952cc); }

/* ─── V2 CALENDAR CELLS ──────────────────────────────────── */

.v2-cal-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(175px, 1fr)); gap: 8px; }
.v2-cal-cell { background: var(--p-surface, #fff); border: 1px solid var(--p-border, #e5e8ef); border-radius: var(--p-radius-sm, 6px); padding: 10px; cursor: pointer; transition: var(--p-transition); border-left: 3px solid #e5e7eb; }
.v2-cal-cell:hover { box-shadow: var(--p-shadow-sm); transform: translateY(-1px); }
.v2-cal-date { font-size: 12px; font-weight: 700; margin-bottom: 4px; color: var(--p-text, #1a1d2b); }
.v2-cal-metrics { display: flex; gap: 8px; font-size: 11px; color: var(--p-text-secondary); margin-bottom: 4px; }
.v2-cal-badges { display: flex; gap: 3px; flex-wrap: wrap; }

/* ─── V2 SCORES ───────────────────────────────────────────── */

.v2-score { padding: 6px 0; }
.v2-score-header { display: flex; justify-content: space-between; font-size: 12px; margin-bottom: 4px; }
.v2-score-track { height: 5px; background: var(--p-border, #e5e8ef); border-radius: 3px; overflow: hidden; }
.v2-score-fill { height: 100%; border-radius: 3px; transition: width 0.4s ease; }

/* ─── V2 MODULE HEALTH ────────────────────────────────────── */

.v2-health-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 8px; }
.v2-health-card { display: flex; align-items: center; gap: 10px; background: var(--p-surface, #fff); border: 1px solid var(--p-border); border-radius: var(--p-radius-sm, 6px); padding: 12px; }
.v2-health-icon { font-size: 20px; }
.v2-health-name { font-size: 13px; font-weight: 600; }
.v2-health-status { font-size: 11px; }

/* ─── V2 SAFETY ───────────────────────────────────────────── */

.v2-safety { display: flex; gap: 8px; align-items: flex-start; padding: 12px 16px; background: var(--p-primary-soft, rgba(51,102,255,0.06)); border-radius: var(--p-radius-sm, 6px); font-size: 12px; color: var(--p-text-secondary, #5b6178); margin-top: 16px; line-height: 1.5; }
.v2-safety-icon { font-size: 14px; flex-shrink: 0; margin-top: 1px; }

/* ─── V2 EMPTY / ERROR ────────────────────────────────────── */

.v2-empty { text-align: center; padding: 32px 16px; }
.v2-empty-icon { font-size: 32px; margin-bottom: 8px; }
.v2-empty-title { font-size: 16px; font-weight: 700; margin-bottom: 4px; }
.v2-empty-text { font-size: 13px; color: var(--p-text-muted); }
.v2-error { display: flex; gap: 8px; align-items: center; padding: 12px 16px; background: var(--p-danger-soft, rgba(229,56,79,0.06)); border-radius: var(--p-radius-sm, 6px); color: var(--p-danger, #e5384f); font-size: 13px; }
.v2-error-icon { font-size: 16px; }

/* ─── V2 SECTION HEADER ──────────────────────────────────── */

.v2-section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.v2-section-title { font-size: 18px; font-weight: 700; color: var(--p-text, #1a1d2b); }
.v2-section-actions { display: flex; gap: 8px; }

/* ─── V2 TABLE ────────────────────────────────────────────── */

.v2-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.v2-table th { text-align: left; padding: 8px 10px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--p-text-muted); border-bottom: 2px solid var(--p-border); }
.v2-table td { padding: 8px 10px; border-bottom: 1px solid var(--p-border-light, #eef0f5); }
.v2-table tr:hover td { background: var(--p-bg-alt, #f1f3f8); }

/* ─── MOBILE ──────────────────────────────────────────────── */

@media (max-width: 768px) {
  .v2-kpi-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .v2-kpi-value { font-size: 22px; }
  .v2-cal-grid { grid-template-columns: 1fr; }
  .v2-tabs { gap: 2px; }
  .v2-tab { padding: 6px 10px; font-size: 12px; }
  .v2-section-header { flex-direction: column; align-items: flex-start; gap: 8px; }
  .v2-card-row { flex-direction: column; }
  .v2-actions { align-self: flex-end; }
  .v2-health-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 480px) {
  .v2-kpi-grid { grid-template-columns: 1fr 1fr; }
  .v2-kpi { padding: 12px; }
  .v2-kpi-value { font-size: 20px; }
  .v2-health-grid { grid-template-columns: 1fr; }
}

/* ─── CALENDAR V2 ─────────────────────────────────────────── */

.cal2-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 8px;
}

.cal2-cell {
  background: var(--p-surface, #fff);
  border: 1px solid var(--p-border, #e5e8ef);
  border-radius: var(--p-radius-sm, 6px);
  padding: 10px;
  cursor: pointer;
  transition: var(--p-transition);
  border-left: 3px solid #e5e7eb;
  min-height: 120px;
}
.cal2-cell:hover { box-shadow: var(--p-shadow-md); transform: translateY(-2px); }
.cal2-weekend { background: var(--p-bg-alt, #f8f9fc); }
.cal2-alert { box-shadow: inset 0 0 0 1px rgba(229,56,79,0.2); }

.cal2-cell-header { display: flex; align-items: baseline; gap: 4px; margin-bottom: 6px; }
.cal2-dow { font-size: 11px; color: var(--p-text-muted); font-weight: 500; }
.cal2-day { font-size: 20px; font-weight: 800; color: var(--p-text); line-height: 1; }
.cal2-month { font-size: 10px; color: var(--p-text-muted); }

.cal2-metrics { display: flex; gap: 10px; margin-bottom: 4px; }
.cal2-metric { display: flex; flex-direction: column; }
.cal2-metric-val { font-size: 13px; font-weight: 700; color: var(--p-text); }
.cal2-metric-label { font-size: 9px; color: var(--p-text-muted); text-transform: uppercase; letter-spacing: 0.03em; }
.cal2-positive { color: var(--p-success) !important; }
.cal2-negative { color: var(--p-danger) !important; }

.cal2-revenue { font-size: 14px; font-weight: 700; color: var(--p-primary); margin-bottom: 4px; }

.cal2-badges { display: flex; gap: 3px; flex-wrap: wrap; margin-bottom: 4px; }
.cal2-event-badge { color: #7c3aed !important; background: rgba(124,58,237,0.08) !important; }

.cal2-indicators { display: flex; gap: 6px; font-size: 10px; color: var(--p-text-muted); }
.cal2-indicator { display: flex; align-items: center; gap: 2px; }
.cal2-indicator-alert { color: var(--p-danger); }

/* List View */
.cal2-list-item { display: flex; align-items: center; gap: 16px; padding: 10px 14px; background: var(--p-surface); border: 1px solid var(--p-border); border-radius: var(--p-radius-sm); margin-bottom: 4px; cursor: pointer; border-left: 3px solid var(--p-border); transition: var(--p-transition); }
.cal2-list-item:hover { box-shadow: var(--p-shadow-xs); }
.cal2-list-date { font-size: 13px; font-weight: 700; min-width: 200px; }
.cal2-list-metrics { display: flex; gap: 12px; font-size: 12px; color: var(--p-text-secondary); flex-wrap: wrap; }

/* Day Detail Drawer */
.cal2-drawer { background: var(--p-surface, #fff); border: 1px solid var(--p-border); border-radius: var(--p-radius-lg, 14px); padding: 24px; margin-top: 16px; box-shadow: var(--p-shadow-lg); }
.cal2-drawer-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.cal2-drawer-title { font-size: 20px; font-weight: 800; color: var(--p-text); }
.cal2-drawer-loading { text-align: center; padding: 32px; color: var(--p-text-muted); }

.cal2-section { margin-bottom: 16px; }
.cal2-section-title { font-size: 13px; font-weight: 700; color: var(--p-text); margin-bottom: 8px; text-transform: uppercase; letter-spacing: 0.03em; }

.cal2-detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 6px; font-size: 13px; }
.cal2-rec-item { padding: 6px 10px; background: var(--p-bg-alt, #f1f3f8); border-radius: var(--p-radius-sm); font-size: 12px; margin-bottom: 4px; display: flex; align-items: center; gap: 6px; }
.cal2-signal { display: flex; gap: 8px; align-items: center; padding: 4px 10px; margin-bottom: 3px; border-radius: 4px; background: var(--p-bg-alt); font-size: 12px; }
.cal2-signal-icon { font-size: 14px; }
.cal2-explanation { font-size: 12px; color: var(--p-text-secondary); line-height: 1.6; padding: 8px; background: var(--p-bg-alt); border-radius: var(--p-radius-sm); }
.cal2-missing { font-size: 11px; color: var(--p-text-muted); margin-bottom: 12px; }
.cal2-price-card { background: var(--p-bg-alt); border-radius: var(--p-radius-sm); padding: 8px; text-align: center; }
.cal2-price-cat { font-size: 10px; color: var(--p-text-muted); text-transform: uppercase; }
.cal2-price-val { font-size: 20px; font-weight: 800; color: var(--p-text); }
.cal2-price-rates { font-size: 10px; color: var(--p-text-muted); }

/* Mobile Calendar */
@media (max-width: 768px) {
  .cal2-grid { grid-template-columns: 1fr 1fr; gap: 6px; }
  .cal2-cell { min-height: auto; padding: 8px; }
  .cal2-day { font-size: 16px; }
  .cal2-revenue { font-size: 12px; }
  .cal2-drawer { padding: 16px; margin-top: 8px; }
  .cal2-drawer-title { font-size: 16px; }
  .cal2-list-date { min-width: auto; }
  .cal2-list-metrics { font-size: 11px; }
}

@media (max-width: 480px) {
  .cal2-grid { grid-template-columns: 1fr; }
  .cal2-metrics { gap: 6px; }
}
