/* ============================================
   DASHBOARD & STATISTICS COMPONENTS
   ============================================ */

/* Statistics Grid Layout */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stats-grid.vertical {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

/* Stat Card Component */
.stat-card {
    background: var(--surface-secondary);
    padding: 12px 16px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-light);
    transition: all 0.2s ease;
}

.stat-card:hover {
    border-color: var(--border-medium);
}

a.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.stat-card-title {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 10px;
}

.stat-card-value {
    font-size: 28px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 5px;
}

.stat-card-subtitle {
    font-size: 12px;
    color: var(--text-tertiary);
}

.stat-card-value-link {
    display: block;
    text-decoration: none;
    color: inherit;
    cursor: pointer;
    transition: opacity 0.2s;
}

.stat-card-value-link:hover {
    opacity: 0.7;
    text-decoration: underline;
}

/* Stat Card Color Variants */
.stat-card.green .stat-card-value,
.stat-card.green .stat-card-value-link {
    color: var(--green-500);
}

.stat-card.red .stat-card-value,
.stat-card.red .stat-card-value-link {
    color: var(--red-500);
}

.stat-card.orange .stat-card-value,
.stat-card.orange .stat-card-value-link {
    color: var(--orange-500);
}

.stat-card.yellow .stat-card-value,
.stat-card.yellow .stat-card-value-link {
    color: var(--amber-500);
}

.stat-card.purple .stat-card-value,
.stat-card.purple .stat-card-value-link {
    color: var(--violet-500);
}

.stat-card.gray .stat-card-value,
.stat-card.gray .stat-card-value-link {
    color: var(--text-tertiary);
}

/* Legacy aliases */
.stat-card.positive .stat-card-value { color: var(--green-500); }
.stat-card.negative .stat-card-value { color: var(--red-500); }
.stat-card.warning  .stat-card-value { color: var(--orange-500); }

/* Metric Card */
.metric-card {
    background: var(--surface-secondary);
    border-radius: 12px;
    padding: 12px 16px;
    border: 1px solid var(--border-light);
    transition: all 0.2s ease;
}

.metric-card:hover {
    border-color: var(--border-medium);
}

.metric-label {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-tertiary);
    font-size: 14px;
    margin-bottom: 4px;
}

.metric-value {
    color: var(--text-primary);
    font-size: 24px;
    font-weight: 700;
    line-height: 40px;
}

.metric-value.positive { color: var(--green-500); }
.metric-value.negative { color: var(--red-500); }

/* ============================================
   CHART COMPONENTS
   ============================================ */

.chart-section {
    background: var(--surface-secondary);
    border-radius: var(--radius-lg);
    padding: 20px;
}

.chart-section > p {
    margin-bottom: 1.5rem;
}

.chart-grid {
    position: absolute;
    inset: 14px 0 0 0;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    pointer-events: none;
    z-index: 0;
}

.chart-grid-line {
    width: 100%;
    border-top: 0.625px dashed rgba(0, 0, 0, 0.3);
}

.chart-grid-line--base {
    width: 100%;
    border-top: 0.625px solid rgba(0, 0, 0, 0.3);
}

.chart-container {
    position: relative;
    height: 300px;
    max-width: 100%;
    overflow: hidden;
    background: var(--surface-secondary);
}

.chart-container canvas {
    max-width: 100% !important;
}

.chart-container-wrapper {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 20px;
}

/* ============================================
   CHART LAYOUT SYSTEM (Operational standard)
   ============================================ */

/* Flex wrapper for y-axis + chart-body */
.chart-wrap {
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

/* Flex wrapper for the x-axis labels row */
.chart-labels-row {
    display: flex;
    gap: 12px;
    margin-top: 6px;
}

/* Y-axis (default 38px — Financial / Casino / Executive / Affiliate) */
.chart-yaxis {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: flex-end;
    padding-right: 6px;
    width: 38px;
    flex-shrink: 0;
    font-size: 12px;
    color: var(--text-secondary);
    box-sizing: border-box;
    padding-top: 14px;
}

/* Wide y-axis (100px — Operational, for longer formatted labels) */
.chart-yaxis--wide {
    width: 100px;
    min-width: 100px;
}

/* Spacer that mirrors default y-axis width in the labels row */
.chart-yaxis-spacer {
    width: 38px;
    min-width: 38px;
    flex-shrink: 0;
}

/* Spacer that mirrors wide y-axis */
.chart-yaxis-spacer--wide {
    width: 100px;
    min-width: 100px;
    flex-shrink: 0;
}

/* Chart body — contains the chart-grid overlay and bars container */
.chart-body {
    flex: 1;
    position: relative;
}

/* Bars container inside chart-body */
.chart-bars {
    padding-top: 14px;
    box-sizing: border-box;
    position: relative;
    z-index: 1;
}

/* Chart height utilities */
.chart-h-300 { height: 300px; }
.chart-h-200 { height: 200px; }
.chart-h-120 { height: 120px; }
.chart-h-100 { height: 100px; }
.chart-h-80  { height: 80px;  }
.chart-h-56  { height: 56px;  }
.chart-h-48  { height: 48px;  }

/* Chart subtitle — section label above a chart row within chart-section */
.chart-subtitle {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

/* JS-generated: individual bar element */
.chart-bar {
    position: relative;
    height: 0;
    min-height: 0;
    border-radius: 12px 12px 0 0;
    max-width: 100px;
    cursor: default;
}

/* JS-generated: value label floating above a bar */
.chart-bar-label {
    position: absolute;
    bottom: calc(100% + 2px);
    left: 50%;
    transform: translateX(-50%);
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
    line-height: 1;
    opacity: 0;
}

/* JS-generated: x-axis date/label span */
.chart-x-label {
    font-size: 12px;
    text-align: center;
    max-width: 100px;
    color: var(--text-secondary);
}

/* ============================================
   DASHBOARD — UNIFIED COMPONENTS
   ============================================ */

/* kpi-card — metric card for executive/financial dashboards */
.kpi-card {
    background: var(--surface-secondary);
    border-radius: 12px;
    padding: 12px 16px;
    min-height: 96px;
    border: 1px solid var(--border-light);
    transition: all 0.2s ease;
}

.kpi-card:hover { border-color: var(--border-medium); }

.kpi-label {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-tertiary);
    font-size: 14px;
    margin-bottom: 4px;
}

.kpi-value {
    color: var(--text-primary);
    font-size: 24px;
    font-weight: 700;
    line-height: 40px;
}

/* Card container — generic dashboard section card */
.card-container {
    background: var(--surface-primary);
    border-radius: var(--radius-lg);
    padding: 20px;
    border: 1px solid var(--border-light);
}

/* Period filter container */
.period-filter {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
    align-items: center;
}

/* Period selector buttons */
.period-btn {
    padding: 8px 16px;
    border-radius: 9999px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-tertiary);
    background: transparent;
    border: 1px solid var(--border-medium);
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
    white-space: nowrap;
    line-height: normal;
}

.period-btn:hover {
    color: var(--text-primary);
    border-color: var(--text-primary);
}

.period-btn.active {
    background: var(--accent-primary);
    color: var(--neutral-50, #fafafa);
    border-color: transparent;
}

.period-btn.active:hover {
    background: var(--accent-active);
    color: var(--neutral-50, #fafafa);
    border-color: transparent;
}

/* Performance overview grid (Financial dashboard) */
.performance-overview-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.po-item {
    flex: 1 1 160px;
    min-width: 140px;
    background: var(--surface-secondary);
    border-radius: 12px;
    padding: 12px 16px;
    border: 1px solid var(--border-light);
}

.po-label {
    font-size: 12px;
    color: var(--text-tertiary);
    margin-bottom: 8px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.po-value {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.3;
}

.po-sub {
    font-size: 12px;
    font-weight: 400;
    color: var(--text-tertiary);
}

.po-sub.currency {
    font-size: 13px;
    color: var(--text-secondary);
}

/* Inline badge (status/segment tags) */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 9999px;
    font-size: 12px;
    font-weight: 500;
    line-height: 20px;
}

.badge.bg-primary   { background: var(--violet-100);      color: var(--violet-700); }
.badge.bg-secondary { background: var(--surface-tertiary); color: var(--text-secondary); }
.badge.bg-danger    { background: #fee2e2;                 color: #b91c1c; }
.badge.bg-warning   { background: #fef3c7;                 color: #b45309; }
.badge.bg-success   { background: #d1fae5;                 color: #065f46; }

/* ============================================
   TABS COMPONENT
   ============================================ */

.tabs-container {
    background: var(--surface-secondary);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    overflow: hidden;
    border: 1px solid var(--border-light);
    border-bottom: none;
}

.tabs {
    display: flex;
    border-bottom: 1px solid var(--border-light);
    background: var(--surface-tertiary);
}

.tab-btn {
    background: transparent;
    border: none;
    padding: 12px 24px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    transition: all 0.2s ease;
    border-right: 1px solid var(--border-light);
    border-bottom: 2px solid transparent;
}

.tab-btn:last-child {
    border-right: none;
}

.tab-btn:hover {
    background: var(--surface-secondary);
    color: var(--text-primary);
}

.tab-btn.active {
    background: var(--surface-secondary);
    color: var(--accent-primary);
    border-bottom: 2px solid var(--accent-primary);
}

.tab-content {
    display: none;
    padding: 20px;
    background: var(--surface-secondary);
}

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