/* ========================================================================
   Variables base
   ======================================================================== */
:root {
    --sidebar-width: 260px;
    /* ancho fijo del sidebar */
    --page-gutter: 40px;
    /* padding lateral del contenido */
    --bg: #0d0f1a;
    --text: #ffffff;

    /* Sidebar */
    --sb-bg-1: #0f1122;
    --sb-bg-2: #12132a;
    --sb-border: #1d2040;
    --sb-hover: #1a1d35;
    --sb-text: #e8ebff;
    --sb-muted: #b3b7ff;

    /* Acentos / botones */
    --accent: #22e58f;
    --accent-strong: #00e676;
    --accent-strong-hover: #00c864;
}

/* ========================================================================
   Reset / base
   ======================================================================== */
* {
    box-sizing: border-box;
}

html,
body {
    height: 100%;
}

body {
    margin: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg);
    color: var(--text);
}

/* ========================================================================
   Sidebar
   ======================================================================== */
.sidebar {
    height: 100vh;
    width: var(--sidebar-width);
    position: fixed;
    left: 0;
    top: 0;
    background: linear-gradient(180deg, var(--sb-bg-1) 0%, var(--sb-bg-2) 100%);
    border-right: 1px solid var(--sb-border);
    padding: 18px 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, .35);

    display: flex;
    /* para empujar el footer al final */
    flex-direction: column;
    gap: 10px;
    overflow-y: auto;
}

/* Marca (opcional) */
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px 18px;
    border-bottom: 1px dashed var(--sb-border);
    margin-bottom: 8px;
}

.brand-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 12px rgba(34, 229, 143, .6);
}

.brand-text {
    color: var(--sb-text);
    font-weight: 700;
    letter-spacing: .3px;
}

/* Navegación */
.sidebar-nav {
    display: grid;
    gap: 6px;
    padding: 4px;
    margin: 0;
    list-style: none;
}

.sidebar .nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--sb-muted);
    text-decoration: none;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid transparent;
    transition: background .15s, color .15s, border .15s, transform .04s;
}

.sidebar .nav-emoji {
    width: 22px;
    text-align: center;
    opacity: .95;
}

.sidebar .nav-link:hover {
    background: var(--sb-hover);
    color: #fff;
    border-color: #2a2e5e;
    transform: translateY(-1px);
}

.sidebar .nav-link.is-active {
    background: #191c3b;
    border-color: #2d3168;
    color: #fff;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .04);
}

/* Footer del sidebar (Cerrar sesión) */
.sidebar-footer {
    margin-top: auto;
    /* baja al final */
    padding: 12px;
    padding-bottom: 18px;
    /* colchón para que no quede tapado */
    border-top: 1px dashed var(--sb-border);
}

.sidebar .nav-link.logout {
    color: #ffb3b3;
}

.sidebar .nav-link.logout:hover {
    background: #2a1a1a;
    border-color: #543232;
    color: #ffdede;
}

/* ========================================================================
   Main content (offset + gutters y centrado de secciones)
   ======================================================================== */
.main-content {
    margin-left: var(--sidebar-width);
    /* offset del sidebar */
    padding: 32px var(--page-gutter);
    /* gutters simétricos */
    color: #fff;
}

/* Centrar y alinear todos los hijos directos del main */
.main-content>* {
    max-width: 1200px;
    margin-left: auto;
    margin-right: auto;
}

h1 {
    font-size: 32px;
    margin-bottom: 20px;
}

/* ========================================================================
   Grid y tarjetas (usado en varias vistas)
   ======================================================================== */
.card-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}

.card {
    background: #141628;
    border: 1px solid #1b1f3e;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0, 0, 0, .25);
    padding: 20px;
}

.card.card-ranking {
    grid-column: span 2;
}

.card h3 {
    margin: 0 0 15px;
    font-size: 22px;
    font-weight: 600;
}

.card p {
    margin: 5px 0;
    font-size: 16px;
}

/* ========================================================================
   Login
   ======================================================================== */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
}

.login-box {
    background-color: #141628;
    padding: 40px;
    border-radius: 16px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, .4);
    text-align: center;
    width: 400px;
}

.login-box h2 {
    margin-bottom: 20px;
    font-size: 26px;
}

.login-box form {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.login-box input {
    width: 90%;
    padding: 12px;
    margin: 10px 0;
    border: none;
    border-radius: 8px;
    background: #1f2235;
    color: #fff;
    font-size: 14px;
}

.login-box button {
    background: var(--accent);
    color: #000;
    border: none;
    padding: 12px;
    border-radius: 8px;
    font-weight: bold;
    width: 90%;
    cursor: pointer;
    transition: background .3s;
    margin-top: 10px;
}

.login-box button:hover {
    background: #1edb7f;
}

/* ========================================================================
   Pedidos (form + tabla)
   ======================================================================== */
.container-pedidos {
    /* el offset general ya lo da .main-content */
    padding: 0 var(--page-gutter) 20px var(--page-gutter);
    color: #fff;
    max-width: 1000px;
    margin-left: auto;
    margin-right: auto;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    height: 100%;
    box-sizing: border-box;
    overflow: hidden;
}

.pedido-form {
    display: flex;
    gap: 20px;
    margin-bottom: 30px;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
}

.select-input,
.input-date {
    background: #1e203d;
    color: #fff;
    border: none;
    padding: 10px 18px;
    border-radius: 10px;
    font-size: 16px;
    outline: none;
    transition: background .3s;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='7'%3E%3Cpath fill='%23fff' d='M0 0l5 7 5-7z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    background-size: 10px 7px;
    min-width: 230px;
    text-align: left;
}

.select-input:hover,
.input-date:hover {
    background: #2a2d4f;
}

.tabla-productos {
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 0 10px rgba(0, 0, 0, .3);
}

.tabla-encabezado,
.fila-producto {
    display: flex;
    align-items: center;
    padding: 12px 20px;
}

.tabla-encabezado {
    background: #222444;
    font-weight: bold;
    border-bottom: 1px solid #333;
}

.fila-producto.par {
    background: #2a2c4c;
}

.fila-producto.impar {
    background: #1f213e;
}

.celda-codigo,
.celda-nombre,
.celda-cantidad {
    flex: 1;
}

.input-cantidad {
    width: 60px;
    padding: 8px;
    border-radius: 6px;
    border: none;
    text-align: center;
    background: #fff;
    color: #000;
    font-weight: bold;
}

.btn-guardar {
    background: #00e676;
    color: #000;
    padding: 12px 25px;
    border: none;
    border-radius: 10px;
    font-weight: bold;
    font-size: 16px;
    cursor: pointer;
    transition: .3s;
}

.btn-guardar:hover {
    background: #00c853;
}

/* ========================================================================
   Top 10 (index)
   ======================================================================== */
.tabla-top10 {
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 0 10px rgba(0, 0, 0, .3);
}

.top10-encabezado,
.top10-fila {
    display: flex;
    align-items: center;
    padding: 12px 20px;
}

.top10-encabezado {
    background: #222444;
    font-weight: bold;
    border-bottom: 1px solid #333;
}

.top10-fila.par {
    background: #2a2c4c;
}

.top10-fila.impar {
    background: #1f213e;
}

.celda-posicion {
    width: 48px;
    text-align: center;
    font-weight: 700;
}

.celda-nombre {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.celda-bandejas {
    width: 100px;
    text-align: center;
    font-weight: 700;
}

/* ========================================================================
   Descargas (botón/inputs heredan de UI)
   ======================================================================== */
.btn-primary {
    background: var(--accent-strong);
    color: #001b10;
    border: none;
    font-weight: 800;
    padding: 12px 18px;
    border-radius: 12px;
    cursor: pointer;
    transition: transform .06s, background .2s, box-shadow .2s;
    box-shadow: 0 8px 24px rgba(0, 230, 118, .15);
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.btn-primary:hover {
    background: var(--accent-strong-hover);
}

.btn-primary:active {
    transform: translateY(1px);
}

.btn-xl {
    padding: 14px 24px;
    font-size: 17px;
}

/* ========================================================================
   Entregas (choferes)
   ======================================================================== */
.entregas-body {
    background: #0d0f1a;
    color: #fff;
}

.entregas-container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 32px 24px 120px;
}

.page-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 18px;
}

.page-header h1 {
    font-size: 44px;
    margin: 0;
    letter-spacing: .3px;
}

.badge-pill {
    background: #1e203d;
    border: 1px solid #2a2d4f;
    color: #bfc3ff;
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 13px;
}

.controls-row {
    display: flex;
    gap: 14px;
    align-items: flex-end;
    flex-wrap: wrap;
    margin: 10px 0 20px;
}

.control {
    min-width: 260px;
}

.control-label {
    display: block;
    font-size: 13px;
    color: #aab;
    margin: 0 0 6px 6px;
}

.ui-select {
    width: 100%;
    background: #1e203d;
    color: #fff;
    border: 1px solid #2a2d4f;
    padding: 12px 14px;
    border-radius: 12px;
    font-size: 16px;
    outline: none;
    transition: border .2s, background .2s;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath fill='%23bfc3ff' d='M0 0l6 8 6-8z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
}

.ui-select:hover {
    border-color: #3a3f6a;
}

.table-head,
.row {
    display: grid;
    grid-template-columns: 160px 160px 1fr;
    gap: 16px;
    align-items: center;
}

.table-head {
    padding: 14px 18px;
    background: #242747;
    font-weight: 800;
    color: #dce0ff;
    letter-spacing: .3px;
}

.table-body {
    padding: 2px 10px 12px;
}

.row {
    padding: 14px 8px 14px 18px;
    border-bottom: 1px solid rgba(255, 255, 255, .06);
}

.row.odd {
    background: rgba(255, 255, 255, .02);
}

.row-empty {
    padding: 24px 18px;
    color: #b5b9ff;
}

.cell.code {
    font-weight: 700;
    letter-spacing: .2px;
}

.cell.pedido {
    font-weight: 700;
}

.qty-input {
    width: 140px;
    max-width: 100%;
    background: #1e203d;
    color: #fff;
    border: 1px solid #2a2d4f;
    border-radius: 12px;
    padding: 10px 12px;
    font-size: 16px;
    outline: none;
}

.qty-input:focus {
    border-color: #3a3f6a;
}

.action-bar {
    position: sticky;
    bottom: 16px;
    display: flex;
    justify-content: flex-end;
    margin-top: 18px;
}

/* Toast */
.toast {
    position: fixed;
    left: 50%;
    bottom: 20px;
    transform: translateX(-50%);
    background: #141628;
    border: 1px solid #243;
    color: #dfe6ff;
    padding: 10px 16px;
    border-radius: 10px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, .35);
    opacity: 0;
    transition: opacity .3s;
    pointer-events: none;
}

.toast.ok {
    border-color: #00e67644;
}

.toast.error {
    border-color: #ff4d6e55;
}

/* ========================================================================
   Clientes (UI moderna)
   ======================================================================== */
.clients-wrapper {
    max-width: 1100px;
}

.clients-header {
    display: flex;
    align-items: center;
    gap: 12px;
}

.clients-header h1 {
    margin: 0 0 10px;
}

.clients-toolbar {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
    margin: 10px 0 22px;
}

.ui-input {
    display: block;
    width: 100%;
    margin: 0;
    background: #1e203d;
    color: #fff;
    border: 1px solid #2a2d4f;
    border-radius: 12px;
    padding: 12px 14px;
    font-size: 16px;
    outline: none;
    transition: border .2s, background .2s;
}

.ui-input:focus {
    border-color: #3a3f6a;
}

.clients-grid {
    grid-template-columns: repeat(2, 1fr);
}

.clients-card {
    padding: 22px;
}

.card-title {
    margin: 0 0 14px;
    font-size: 18px;
    font-weight: 700;
}

.clients-form {
    display: grid;
    gap: 12px;
}

.btn-fill {
    width: 100%;
    color: #0d0f1a;
    font-weight: 700;
}

.clients-list-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 8px;
}

.muted {
    color: #aab;
}

.clients-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 10px;
}

.client-item {
    background: #151833;
    border: 1px solid #20244a;
    border-radius: 12px;
    padding: 12px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: transform .05s, border .15s, background .15s;
}

.client-item:hover {
    border-color: #2e356a;
    background: #181c3b;
}

.client-item.hidden {
    display: none;
}

.client-name {
    font-weight: 600;
    letter-spacing: .2px;
}

.empty-state {
    margin-top: 12px;
    color: #b5b9ff;
    background: #12142b;
    border: 1px dashed #2a2d4f;
    border-radius: 12px;
    padding: 16px;
    text-align: center;
}

/* ========================================================================
   Responsive
   ======================================================================== */
@media (max-width: 960px) {
    .clients-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 820px) {

    /* El contenido deja de tener offset cuando ocultes el sidebar en móvil */
    .main-content {
        margin-left: 0;
        padding: 72px 16px 24px;
    }

    .main-content>* {
        max-width: 100%;
    }

    .entregas-container {
        padding: 24px 14px 120px;
    }

    .page-header h1 {
        font-size: 34px;
    }

    .table-head,
    .row {
        grid-template-columns: 110px 110px 1fr;
        gap: 10px;
    }

    .qty-input {
        width: 100%;
    }

    .action-bar {
        justify-content: center;
    }

    /* Pedidos compacto */
    .pedido-form {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
        margin-bottom: 18px;
    }

    .select-input,
    .input-date {
        width: 100%;
        min-width: 0;
    }

    .tabla-encabezado,
    .fila-producto,
    .top10-encabezado,
    .top10-fila {
        padding: 10px 12px;
    }

    .input-cantidad {
        width: 72px;
        padding: 8px;
    }

    .btn-guardar {
        position: sticky;
        bottom: 12px;
        width: 100%;
        max-width: 480px;
        margin: 16px auto 0;
        display: block;
    }

    .celda-posicion {
        width: 40px;
    }

    .celda-bandejas {
        width: 84px;
    }

    .celda-nombre {
        flex: 1;
    }
}

/* Botón base (antes era solo para login, ahora global) */
.btn-login {
    display: inline-block;
    padding: 12px 24px;
    font-size: 16px;
    font-weight: bold;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    text-align: center;
    transition: all 0.3s ease;
    background-color: #00e676;
    /* Verde moderno */
    color: white;
}

/* Efecto hover */
.btn-login:hover {
    background-color: #00e676;
    transform: scale(1.03);
}

/* Variante rellena (ej: botón de clientes) */
.btn-fill {
    background-color: #00e676;
    /* Azul moderno */
    color: white;
}

.btn-fill:hover {
    background-color: #00e676;
}

.toast {
    position: fixed;
    left: 50%;
    bottom: 24px;
    transform: translateX(-50%) translateY(20px);
    min-width: 280px;
    max-width: 520px;
    padding: 14px 16px;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, .08);
    background: linear-gradient(180deg, #141628 0%, #0f1224 100%);
    color: #e9ecff;
    box-shadow: 0 14px 40px rgba(0, 0, 0, .35), 0 0 0 1px rgba(255, 255, 255, .02) inset;
    opacity: 0;
    pointer-events: none;
    transition: opacity .25s ease, transform .25s ease, box-shadow .25s ease;
    z-index: 9999;
    font-size: 15px;
    letter-spacing: .2px;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
    pointer-events: auto;
}

.toast.ok {
    border-color: #1ddf8c44;
    box-shadow: 0 16px 44px rgba(29, 223, 140, .18), 0 0 0 1px rgba(255, 255, 255, .02) inset;
}

.toast.error {
    border-color: #ff5c7a55;
    box-shadow: 0 16px 44px rgba(255, 92, 122, .18), 0 0 0 1px rgba(255, 255, 255, .02) inset;
}

.toast::before {
    content: "";
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 10px;
    vertical-align: middle;
    background: #7aa2ff;
}

.toast.ok::before {
    background: #22e58f;
}

.toast.error::before {
    background: #ff5c7a;
}