/* ==========================================================
   dashboard-layout.css  ·  Orden de la parte baja del Dashboard
   Cargar en index.html DESPUÉS de tema-pro.css (y de venta-panel.css
   si lo usás), así pisa los estilos anteriores sin borrarlos:

       <link rel="stylesheet" href="dashboard-layout.css">

   Qué arregla:
   - Las 4 tarjetas de alertas (stock, pedidos, por cobrar, ganancia)
     suben justo debajo de los gráficos, en vez de quedar al fondo.
   - "Últimas ventas" y el resto forman una grilla pareja, sin el
     hueco vacío al costado.
   - Textos más grandes y legibles (antes 9-10 px).
   - Nada se corta ni se desborda hacia los costados.
   Usa solo tus colores --ba-*, así que anda igual en modo oscuro.
   ========================================================== */

/* ---------- 0. Sin barra de desplazamiento horizontal ----------
   La barra superior (margen -28 px) se pasaba unos píxeles del ancho
   real de la pantalla y generaba un scroll lateral en toda la app. */
.main-content-area { overflow-x: hidden; }

/* ---------- 1. Orden vertical del dashboard ---------- */
.dashboard-wrapper {
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-width: 0;
}
.dashboard-wrapper > .dashboard-title-row { order: 0; }
.dashboard-wrapper > .dash-ref-layout     { order: 1; margin-bottom: 0; }
.dashboard-wrapper > .dashboard-alert-strip { order: 2; }
.dashboard-wrapper > .dash-ref-bottom     { order: 3; }

/* ---------- 2. Tarjetas de alerta ---------- */
.dashboard-alert-strip {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
}
.dashboard-alert-strip .dashboard-alert-card {
    flex-direction: row;
    align-items: center;
    gap: 12px;
    min-height: 72px;
    padding: 14px 16px;
    margin: 0;
    border-radius: 16px;
    cursor: pointer;
}
.dashboard-alert-strip .dashboard-alert-icon {
    flex: none;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    font-size: 18px;
    background: var(--ba-surface-secondary);
}
.dashboard-alert-strip .dashboard-alert-icon .ic svg { width: 20px; height: 20px; }
.dashboard-alert-strip .dashboard-alert-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}
.dashboard-alert-strip .dashboard-alert-value {
    font-size: 20px;
    font-weight: 800;
    line-height: 1.1;
    white-space: nowrap;
}
.dashboard-alert-strip .dashboard-alert-label {
    font-size: 12px;
    line-height: 1.3;
}

/* ---------- 3. Grilla de la parte baja ----------
   Columnas iguales a las de arriba: dos columnas parejas + la
   columna angosta de 310 px que queda bajo "Actividad reciente". */
.dash-ref-bottom {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 310px;
    gap: 16px;
    align-items: stretch;
    margin: 0;
}
/* Las dos columnas viejas dejan de existir: sus tarjetas van directo a la grilla */
.dash-ref-bottom > .dashboard-center-column,
.dash-ref-bottom > .dashboard-side-column {
    display: contents;
}
.dash-ref-bottom .card {
    margin: 0;
    min-width: 0;
}
.dash-ref-bottom .dashboard-lower-card     { grid-column: 1 / span 2; order: 1; }
.dash-ref-bottom .dashboard-side-stock     { grid-column: 3;          order: 2; }
.dash-ref-bottom .dashboard-side-inventory { grid-column: 1 / span 2; order: 3; }
.dash-ref-bottom .dashboard-side-cash      { grid-column: 3;          order: 4; }

/* ---------- 4. Últimas ventas ---------- */
.dash-ref-bottom .dashboard-lower-card .table-container { overflow-x: auto; }
.dash-ref-bottom .dashboard-lower-card th,
.dash-ref-bottom .dashboard-lower-card td { font-size: 12px; }

/* ---------- 5. Para reponer (se ven los 5 productos, sin scroll) ---------- */
.dashboard-side-stock .dash-mini-list {
    max-height: none;
    overflow: visible;
}
.dashboard-side-stock .dash-mini-item,
.dashboard-side-inventory .dash-mini-item {
    font-size: 12px;
    padding: 9px 0;
    gap: 9px;
}
.dash-ref-bottom .dash-mini-name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.dash-ref-bottom .dash-mini-sub { font-size: 10.5px; }
.dash-ref-bottom .dash-mini-val { font-size: 12px; }

/* ---------- 6. Flujo de caja ---------- */
.dashboard-side-cash .dash-caja-grid {
    grid-template-columns: 1fr;
    gap: 8px;
    margin-bottom: 12px;
}
.dashboard-side-cash .dash-caja-box {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    border-radius: 10px;
}
.dashboard-side-cash .dash-caja-box span { font-size: 11px; }
.dashboard-side-cash .dash-caja-box b   { font-size: 15px; }
.dashboard-side-cash .dash-caja-efectivo { margin-top: 0; gap: 8px; }
.dashboard-side-cash .t-row { font-size: 12px; }

/* ---------- 7. Inventario (tarjeta ancha: 2 + 3 datos, todos legibles) ---------- */
.dashboard-side-inventory {
    display: flex;
    flex-direction: column;
}
.dashboard-side-inventory .dash-inventory-metrics {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin-top: 10px;
}
.dashboard-side-inventory .dash-inventory-metrics > div {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    padding: 14px 16px;
    border-radius: 12px;
}
.dashboard-side-inventory .dash-inventory-metrics span { font-size: 12px; }
.dashboard-side-inventory .dash-inventory-metrics b {
    font-size: 20px;
    font-weight: 800;
    margin: 0;
    font-variant-numeric: tabular-nums;
}
.dashboard-side-inventory .dash-inv-summary {
    flex: 1;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    margin-top: 12px;
    padding-top: 0;
    border-top: 0;
    font-size: 12px;
}
.dashboard-side-inventory .dash-inv-summary > div {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    padding: 14px 16px;
    border: 1px solid var(--ba-border);
    border-radius: 12px;
}
.dashboard-side-inventory .dash-inv-summary b {
    font-size: 18px;
    font-weight: 800;
    margin: 0;
    font-variant-numeric: tabular-nums;
    overflow-wrap: anywhere;
}

/* ---------- 8. Pantallas medianas ---------- */
@media (max-width: 1200px) {
    .dash-ref-bottom { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .dash-ref-bottom .dashboard-lower-card     { grid-column: 1 / -1; order: 1; }
    .dash-ref-bottom .dashboard-side-stock     { grid-column: auto;   order: 2; }
    .dash-ref-bottom .dashboard-side-cash      { grid-column: auto;   order: 3; }
    .dash-ref-bottom .dashboard-side-inventory { grid-column: 1 / -1; order: 4; }
    .dashboard-alert-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ---------- 9. Celular / ventana angosta ---------- */
@media (max-width: 760px) {
    .dash-ref-bottom { grid-template-columns: minmax(0, 1fr); }
    .dash-ref-bottom .dashboard-lower-card,
    .dash-ref-bottom .dashboard-side-stock,
    .dash-ref-bottom .dashboard-side-cash,
    .dash-ref-bottom .dashboard-side-inventory { grid-column: 1; }
    .dashboard-side-inventory .dash-inventory-metrics,
    .dashboard-side-inventory .dash-inv-summary { grid-template-columns: minmax(0, 1fr); }
}


/* ==========================================================
   10. Acentos de color del Dashboard
   Inspirado en la referencia visual elegida: cada sección tiene
   su propio color, pero sobre superficies muy claras para no
   saturar la pantalla.
   ========================================================== */
.dashboard-wrapper .dashboard-reference-card {
    position: relative;
    overflow: hidden;
}

.dashboard-wrapper .dashboard-reference-card::before {
    content: "";
    position: absolute;
    inset: 0 0 auto 0;
    height: 3px;
    background: var(--dash-accent, #2f6df6);
    opacity: .85;
}

.dash-section-icon {
    width: 34px;
    height: 34px;
    min-width: 34px;
    display: inline-grid;
    place-items: center;
    border-radius: 11px;
    margin-right: 9px;
    font-size: 17px;
    line-height: 1;
    background: var(--dash-soft, #eaf2ff);
    color: var(--dash-accent, #2f6df6);
    vertical-align: middle;
}

.dash-section-icon .ic,
.dash-section-icon .ic svg {
    width: 18px;
    height: 18px;
    color: currentColor;
    stroke: currentColor;
}

.dashboard-section-title {
    display: flex;
    align-items: center;
    min-height: 34px;
}

.dash-title-blue { --dash-accent:#2f6df6; --dash-soft:#eaf2ff; }
.dash-title-green { --dash-accent:#10b981; --dash-soft:#e5faf2; }
.dash-title-purple { --dash-accent:#8b5cf6; --dash-soft:#f0e9ff; }
.dash-title-orange { --dash-accent:#f59e0b; --dash-soft:#fff4dd; }

.dashboard-chart-card { --dash-accent:#2f6df6; }
.dashboard-payment-card { --dash-accent:#10b981; }
.dashboard-payment-card::before { background:#10b981; }
.dashboard-reference-card:has(.reference-top-products) { --dash-accent:#8b5cf6; }
.dashboard-reference-card:has(.dashboard-activity-list) { --dash-accent:#f59e0b; }
.quick-access-card { --dash-accent:#2f6df6; }
.dashboard-lower-card { --dash-accent:#2f6df6; }
.dashboard-side-stock { --dash-accent:#10b981; }
.dashboard-side-cash { --dash-accent:#f59e0b; }
.dashboard-side-inventory { --dash-accent:#10b981; }

/* Tarjetas inferiores: pequeños fondos pastel para reforzar la jerarquía. */
.dashboard-side-stock .dash-mini-item {
    background: #f0fbf7;
    border-radius: 10px;
    padding: 9px 10px;
    margin: 5px 0;
}
.dashboard-side-cash .dash-caja-box.in {
    background:#e9fbf4;
    border:1px solid #d2f5e8;
}
.dashboard-side-cash .dash-caja-box.out {
    background:#fff6e5;
    border:1px solid #ffebc4;
}
.dashboard-side-cash .dash-caja-box.net {
    background:#eef2ff;
    border:1px solid #dde5ff;
}
.dashboard-side-inventory .dash-inventory-metrics > div {
    background:#effaf6;
    border:1px solid #d8f3e9;
}
.dashboard-side-inventory .dash-inv-summary > div {
    background:#faf7ff;
}

/* Accesos rápidos: cada acción hereda uno de los colores del dashboard. */
.quick-access-grid button {
    border:1px solid var(--ba-border);
    box-shadow:none;
}
.quick-access-grid button:nth-child(1) { background:#edf4ff; color:#08877f; }
.quick-access-grid button:nth-child(2) { background:#eafaf4; color:#059669; }
.quick-access-grid button:nth-child(3) { background:#fff5df; color:#d97706; }
.quick-access-grid button:nth-child(4) { background:#f2ecff; color:#7c3aed; }
.quick-access-grid button span { color:currentColor; }

/* Barra de alertas: cuatro colores coherentes con las tarjetas superiores. */
.dashboard-alert-strip .dashboard-alert-card:nth-child(1) {
    background:#effaf6;
    border-color:#d8f3e9;
}
.dashboard-alert-strip .dashboard-alert-card:nth-child(2) {
    background:#fff7e8;
    border-color:#ffebc4;
}
.dashboard-alert-strip .dashboard-alert-card:nth-child(3) {
    background:#f3eeff;
    border-color:#e6dcff;
}
.dashboard-alert-strip .dashboard-alert-card:nth-child(4) {
    background:#fff0f2;
    border-color:#ffd8dd;
}
.dashboard-alert-strip .dashboard-alert-card:nth-child(1) .dashboard-alert-icon { background:#dff7ec; color:#059669; }
.dashboard-alert-strip .dashboard-alert-card:nth-child(2) .dashboard-alert-icon { background:#fff0cf; color:#d97706; }
.dashboard-alert-strip .dashboard-alert-card:nth-child(3) .dashboard-alert-icon { background:#e8ddff; color:#7c3aed; }
.dashboard-alert-strip .dashboard-alert-card:nth-child(4) .dashboard-alert-icon { background:#ffdfe3; color:#e11d48; }

/* Modo oscuro: conservar la misma lógica cromática, con superficies translúcidas. */
:root[data-theme="dark"] .dashboard-side-stock .dash-mini-item { background:rgba(16,185,129,.09); border-color:rgba(16,185,129,.18); }
:root[data-theme="dark"] .dashboard-side-cash .dash-caja-box.in { background:rgba(16,185,129,.09); border-color:rgba(16,185,129,.18); }
:root[data-theme="dark"] .dashboard-side-cash .dash-caja-box.out { background:rgba(245,158,11,.10); border-color:rgba(245,158,11,.18); }
:root[data-theme="dark"] .dashboard-side-cash .dash-caja-box.net { background:rgba(75,140,255,.10); border-color:rgba(75,140,255,.18); }
:root[data-theme="dark"] .dashboard-side-inventory .dash-inventory-metrics > div { background:rgba(16,185,129,.08); border-color:rgba(16,185,129,.16); }
:root[data-theme="dark"] .dashboard-side-inventory .dash-inv-summary > div { background:rgba(139,92,246,.08); }
:root[data-theme="dark"] .quick-access-grid button:nth-child(1) { background:rgba(75,140,255,.12); }
:root[data-theme="dark"] .quick-access-grid button:nth-child(2) { background:rgba(39,211,165,.11); }
:root[data-theme="dark"] .quick-access-grid button:nth-child(3) { background:rgba(255,194,77,.11); }
:root[data-theme="dark"] .quick-access-grid button:nth-child(4) { background:rgba(178,123,255,.11); }
:root[data-theme="dark"] .dashboard-alert-strip .dashboard-alert-card:nth-child(1) { background:rgba(16,185,129,.08); border-color:rgba(16,185,129,.16); }
:root[data-theme="dark"] .dashboard-alert-strip .dashboard-alert-card:nth-child(2) { background:rgba(245,158,11,.08); border-color:rgba(245,158,11,.16); }
:root[data-theme="dark"] .dashboard-alert-strip .dashboard-alert-card:nth-child(3) { background:rgba(139,92,246,.08); border-color:rgba(139,92,246,.16); }
:root[data-theme="dark"] .dashboard-alert-strip .dashboard-alert-card:nth-child(4) { background:rgba(225,29,72,.08); border-color:rgba(225,29,72,.16); }

@media (max-width: 760px) {
    .dash-section-icon { width:30px; height:30px; min-width:30px; font-size:15px; border-radius:9px; }
}
