/* =============================================
   Compras – Dashboard Resumen
   Premium Dark Glassmorphism (matches Desarrollo)
   Uses --pv-* tokens from desarrollo/main.css
   ============================================= */

/* ── Dashboard Header ──────────────────────── */
.cp-dash-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 16px;
}

.cp-dash-header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.cp-dash-title {
    font-family: var(--pv-font-ui, 'Inter', system-ui, sans-serif);
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--pv-text-primary, #e2e8f0);
    margin: 0;
    letter-spacing: -0.02em;
}

.cp-dash-subtitle {
    color: var(--pv-text-secondary, #64748b);
    font-size: 0.85rem;
    margin: 4px 0 0 0;
}

/* ── Navigation Controls ───────────────────── */
.cp-dash-nav {
    display: flex;
    align-items: center;
    gap: 12px;
}

.cp-btn-refresh {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--pv-card-surface, rgba(18, 24, 40, 0.75));
    color: #48BB78;
    border: 1px solid rgba(72, 187, 120, 0.3);
    padding: 6px 14px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.85rem;
    transition: all 0.2s var(--pv-ease-out, ease);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.cp-btn-refresh:hover {
    background: rgba(72, 187, 120, 0.1);
    border-color: rgba(72, 187, 120, 0.5);
    transform: translateY(-1px);
}

.cp-year-nav {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--pv-card-surface, rgba(18, 24, 40, 0.75));
    padding: 6px 12px;
    border-radius: 10px;
    border: 1px solid var(--pv-card-border, rgba(56, 73, 107, 0.25));
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.cp-year-btn {
    background: none;
    border: none;
    color: #63B3ED;
    cursor: pointer;
    font-size: 1.1rem;
    padding: 4px 8px;
    border-radius: 6px;
    transition: all 0.15s ease;
}

.cp-year-btn:hover {
    background: rgba(99, 179, 237, 0.1);
}

.cp-year-display {
    color: var(--pv-text-primary, #e2e8f0);
    font-weight: 700;
    font-size: 1.05rem;
    min-width: 50px;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

/* ── Main Grid ─────────────────────────────── */
.cp-dash-grid {
    display: grid;
    grid-template-rows: auto 1fr;
    gap: 16px;
}

/* ── KPI Cards Row ─────────────────────────── */
.cp-kpi-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.cp-kpi-card {
    background: var(--pv-card-surface, rgba(18, 24, 40, 0.75));
    backdrop-filter: var(--pv-glass-blur, blur(12px));
    -webkit-backdrop-filter: var(--pv-glass-blur, blur(12px));
    border: 1px solid var(--pv-card-border, rgba(56, 73, 107, 0.25));
    border-radius: 12px;
    padding: 14px;
    position: relative;
    overflow: hidden;
    transition: transform 0.2s var(--pv-ease-out, ease), box-shadow 0.2s;
}

.cp-kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--pv-glow-cyan, 0 0 20px rgba(34, 211, 238, 0.08));
    border-color: rgba(99, 179, 237, 0.2);
}

/* Top accent line */
.cp-kpi-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: linear-gradient(90deg, var(--pv-accent, #3b82f6), rgba(99, 179, 237, 0.6));
    opacity: 0.7;
}

.cp-kpi-top {
    display: flex;
    justify-content: space-between;
}

.cp-kpi-label {
    color: var(--pv-text-secondary, #64748b);
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    font-family: var(--pv-font-ui, 'Inter', system-ui, sans-serif);
}

.cp-kpi-change {
    font-size: 0.78rem;
    color: #48BB78;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.cp-kpi-value-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    margin-top: 4px;
}

.cp-kpi-value {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--pv-text-primary, #e2e8f0);
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.02em;
}

.cp-kpi-spark {
    height: 35px;
    margin-top: 8px;
}

/* ── Analytics Grid ────────────────────────── */
.cp-analytics-grid {
    display: grid;
    grid-template-columns: 7fr 3fr;
    gap: 16px;
}

/* ── Chart Panel ───────────────────────────── */
.cp-chart-panel {
    background: var(--pv-card-surface, rgba(18, 24, 40, 0.75));
    backdrop-filter: var(--pv-glass-blur, blur(12px));
    -webkit-backdrop-filter: var(--pv-glass-blur, blur(12px));
    border: 1px solid var(--pv-card-border, rgba(56, 73, 107, 0.25));
    border-radius: 14px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    max-height: 520px;
}

.cp-chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.cp-chart-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.cp-chart-title {
    color: var(--pv-text-primary, #e2e8f0);
    font-family: var(--pv-font-ui, 'Inter', system-ui, sans-serif);
    font-size: 0.9rem;
    font-weight: 700;
    margin: 0;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.cp-btn-back {
    display: none;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    background: var(--pv-card-surface, rgba(18, 24, 40, 0.75));
    border: 1px solid var(--pv-card-border, rgba(56, 73, 107, 0.25));
    border-radius: 8px;
    color: var(--pv-text-primary, #e2e8f0);
    cursor: pointer;
    font-weight: 600;
    font-size: 0.78rem;
    transition: all 0.15s ease;
}

.cp-btn-back:hover {
    background: rgba(99, 179, 237, 0.1);
    border-color: rgba(99, 179, 237, 0.3);
}

.cp-chart-canvas-wrap {
    flex: 1;
    position: relative;
    min-height: 300px;
}

/* ── Daily Detail Table ────────────────────── */
.cp-daily-list {
    margin-top: 16px;
    overflow-y: auto;
    flex: 1;
    border-top: 1px solid var(--pv-card-border, rgba(56, 73, 107, 0.25));
}

.cp-daily-table {
    width: 100%;
    border-collapse: collapse;
    color: var(--pv-text-secondary, #94a3b8);
    font-size: 0.83rem;
}

.cp-daily-table thead tr {
    text-align: left;
    color: var(--pv-text-secondary, #64748b);
    font-size: 0.75rem;
    border-bottom: 1px solid var(--pv-card-border, rgba(56, 73, 107, 0.25));
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.cp-daily-table th {
    padding: 10px 4px;
    font-weight: 700;
}

.cp-daily-table td {
    padding: 8px 4px;
    border-bottom: 1px solid rgba(56, 73, 107, 0.12);
}

.cp-daily-table tbody tr:hover td {
    background: rgba(99, 179, 237, 0.04);
}

/* ── Side Stack ────────────────────────────── */
.cp-side-stack {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.cp-side-panel {
    background: var(--pv-card-surface, rgba(18, 24, 40, 0.75));
    backdrop-filter: var(--pv-glass-blur, blur(12px));
    -webkit-backdrop-filter: var(--pv-glass-blur, blur(12px));
    border: 1px solid var(--pv-card-border, rgba(56, 73, 107, 0.25));
    border-radius: 14px;
    padding: 18px;
    flex: 1;
    min-height: 240px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.cp-side-title {
    color: var(--pv-text-secondary, #64748b);
    font-family: var(--pv-font-ui, 'Inter', system-ui, sans-serif);
    font-size: 0.72rem;
    font-weight: 700;
    margin: 0 0 12px 0;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.cp-side-chart-wrap {
    height: 180px;
    position: relative;
}

.cp-provider-list {
    height: 100%;
    overflow-y: auto;
    padding-right: 5px;
}

/* Custom scrollbar for provider list */
.cp-provider-list::-webkit-scrollbar {
    width: 4px;
}

.cp-provider-list::-webkit-scrollbar-track {
    background: transparent;
}

.cp-provider-list::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.15);
    border-radius: 2px;
}

/* ── Products Section ──────────────────────── */
.cp-products-section {
    background: var(--pv-card-surface, rgba(18, 24, 40, 0.75));
    backdrop-filter: var(--pv-glass-blur, blur(12px));
    -webkit-backdrop-filter: var(--pv-glass-blur, blur(12px));
    border: 1px solid var(--pv-card-border, rgba(56, 73, 107, 0.25));
    border-radius: 14px;
    padding: 20px;
    margin-top: 16px;
}

.cp-products-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.cp-products-title {
    color: var(--pv-text-primary, #e2e8f0);
    font-family: var(--pv-font-ui, 'Inter', system-ui, sans-serif);
    font-size: 0.9rem;
    font-weight: 700;
    margin: 0;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.cp-products-subtitle {
    color: var(--pv-text-secondary, #64748b);
    font-size: 0.73rem;
}

.cp-products-list {
    max-height: 400px;
    overflow-y: auto;
}

/* ── Empty State ───────────────────────────── */
.cp-empty-state {
    color: var(--pv-text-secondary, #64748b);
    text-align: center;
    padding: 30px;
}

/* ── JS-Generated: Provider Progress Bars ──── */
.cp-provider-item {
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    font-size: 0.85em;
}

.cp-provider-rank {
    width: 20px;
    color: var(--pv-text-secondary, #64748b);
    font-weight: bold;
    font-size: 0.9em;
    font-variant-numeric: tabular-nums;
}

.cp-provider-detail {
    flex: 1;
}

.cp-provider-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 2px;
}

.cp-provider-name {
    color: var(--pv-text-primary, #e2e8f0);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 140px;
}

.cp-provider-amount {
    color: var(--pv-text-secondary, #94a3b8);
    font-variant-numeric: tabular-nums;
}

.cp-provider-bar-bg {
    height: 6px;
    background: rgba(56, 73, 107, 0.3);
    border-radius: 3px;
    overflow: hidden;
}

.cp-provider-bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.4s ease;
}

/* ── JS-Generated: Products Table ──────────── */
.cp-prod-table {
    width: 100%;
    border-collapse: collapse;
    color: var(--pv-text-secondary, #94a3b8);
    font-size: 0.83rem;
}

.cp-prod-table thead tr {
    text-align: left;
    color: var(--pv-text-secondary, #64748b);
    font-size: 0.73rem;
    border-bottom: 2px solid var(--pv-card-border, rgba(56, 73, 107, 0.35));
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.cp-prod-table th {
    padding: 10px 8px;
    font-weight: 700;
}

.cp-prod-table td {
    padding: 12px 8px;
    border-bottom: 1px solid rgba(56, 73, 107, 0.12);
}

.cp-prod-table tbody tr {
    transition: background 0.15s ease;
}

.cp-prod-table tbody tr:hover td {
    background: rgba(99, 179, 237, 0.04);
}

.cp-prod-name {
    font-weight: 600;
    color: var(--pv-text-primary, #e2e8f0);
}

.cp-prod-sku {
    font-size: 0.8em;
    color: var(--pv-text-secondary, #64748b);
    font-family: var(--pv-font-mono, 'JetBrains Mono', monospace);
}

.cp-val-green {
    color: #48BB78;
    font-weight: 600;
}

.cp-val-blue {
    color: #63B3ED;
    font-weight: 600;
}

.cp-val-sub {
    font-size: 0.8em;
    color: var(--pv-text-secondary, #64748b);
}

/* ── JS-Generated: Filter Badge ────────────── */
.cp-filter-badge {
    background: rgba(66, 153, 225, 0.15);
    color: #90CDF4;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 0.7em;
    font-weight: 700;
    margin-left: 8px;
    cursor: pointer;
    transition: background 0.15s ease;
    border: 1px solid rgba(66, 153, 225, 0.2);
}

.cp-filter-badge:hover {
    background: rgba(66, 153, 225, 0.25);
}

/* ── Table containers (shared) ─────────────── */
.table-container {
    width: 100%;
    overflow-x: auto;
    margin-top: 15px;
    background: rgba(255, 255, 255, 0.01);
    border-radius: 12px;
}

.generator-table-container {
    min-height: 500px;
    padding-bottom: 300px;
    overflow-y: visible !important;
}

/* ── Responsive ────────────────────────────── */
@media (max-width: 1024px) {
    .cp-analytics-grid {
        grid-template-columns: 1fr;
    }

    .cp-side-stack {
        flex-direction: row;
    }
}

@media (max-width: 640px) {
    .cp-dash-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .cp-side-stack {
        flex-direction: column;
    }

    .cp-kpi-row {
        grid-template-columns: 1fr;
    }
}

.text-right {
    text-align: right;
}