/* valu-admin/public/assets/css/admin.css */
:root {
    --bg-cream: #F9F8F4;
    --surface-white: #FFFFFF;
    --primary-emerald: #194538;
    --primary-emerald-hover: #123329;
    --emerald-soft: #E4EFEA;
    --accent-camel: #C8A98E;
    --text-main: #1C201E;
    --text-muted: #6E716D;
    --border-soft: #E6E4DD;
    --warning: #B45309;
    --warning-soft: #FEF3C7;
    --success: #15803D;
    --success-soft: #DCFCE7;
    --danger: #B91C1C;
    --danger-soft: #FEE2E2;
    --font-serif: 'Fraunces', Georgia, serif;
    --font-sans: 'Plus Jakarta Sans', -apple-system, sans-serif;
    --radius-md: 14px;
    --radius-pill: 9999px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    background-color: var(--bg-cream);
    color: var(--text-main);
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: 1.5;
}

a { color: inherit; text-decoration: none; }

.admin-shell {
    display: flex;
    align-items: flex-start;
    min-height: 100vh;
}

/* --- Sidebar --- */
.admin-sidebar {
    width: 260px;
    height: 100vh;
    position: sticky;
    top: 0;
    background-color: var(--surface-white);
    border-right: 1px solid var(--border-soft);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.sidebar-brand {
    height: 88px;
    padding: 0 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
    overflow: hidden;
}
.sidebar-brand__img { width: 42px; height: auto; }
.sidebar-brand__copy { display: flex; flex-direction: column; line-height: 1.05; }
.sidebar-brand__sub { font-size: 9px; letter-spacing: 0.16em; color: var(--text-muted); font-weight: 600; }
.sidebar-brand__title { font-family: var(--font-serif); font-size: 24px; font-weight: 700; }
.brand-dot { color: var(--accent-camel); }

.sidebar-divider { margin: 0 20px; border-top: 1px solid var(--border-soft); }

.sidebar-nav { flex: 1; padding: 24px 16px; display: flex; flex-direction: column; gap: 6px; }
.sidebar-section-label { font-size: 10px; font-weight: 700; letter-spacing: 0.14em; color: var(--text-muted); padding: 0 12px 8px; }

.sidebar-link {
    height: 42px;
    padding: 0 14px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text-muted);
    font-weight: 500;
    transition: all 0.2s;
}
.sidebar-link i { font-size: 19px; }
.sidebar-link:hover { background-color: var(--bg-cream); color: var(--text-main); }
.sidebar-link.is-active {
    background-color: var(--emerald-soft);
    color: var(--primary-emerald);
    font-weight: 600;
}
.sidebar-counter {
    margin-left: auto;
    background-color: var(--primary-emerald);
    color: #FFFFFF;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 999px;
}

.sidebar-note {
    margin: 0 20px 20px;
    padding: 16px;
    border-radius: 12px;
    background-color: var(--bg-cream);
    border: 1px solid var(--border-soft);
}
.sidebar-note i { color: var(--primary-emerald); font-size: 18px; margin-bottom: 6px; display: block; }
.sidebar-note__title { font-family: var(--font-serif); font-size: 15px; font-weight: 600; }
.sidebar-note__desc { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

.sidebar-footer {
    height: 56px;
    padding: 0 24px;
    border-top: 1px solid var(--border-soft);
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    color: var(--text-muted);
}

/* --- Main Area --- */
.admin-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 100vh;
}

.admin-content {
    padding: 32px;
    max-width: 1320px;
    width: 100%;
    margin: 0 auto; /* Sin margin-top auto para que quede pegado al topbar */
}

.admin-topbar {
    height: 72px;
    background-color: var(--surface-white);
    border-bottom: 1px solid var(--border-soft);
    padding: 0 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.admin-topbar__left, .admin-topbar__right { display: flex; align-items: center; gap: 14px; }
.admin-breadcrumb { font-size: 13px; color: var(--text-muted); }
.admin-breadcrumb strong { color: var(--text-main); }

.admin-user-pill { display: flex; align-items: center; gap: 10px; }
.admin-avatar {
    width: 34px; height: 34px; border-radius: 50%;
    background-color: var(--primary-emerald); color: #FFFFFF;
    font-family: var(--font-serif); font-weight: 600;
    display: flex; align-items: center; justify-content: center;
}
.admin-user-name { font-size: 12px; font-weight: 600; line-height: 1.2; }
.admin-user-role { font-size: 10px; color: var(--text-muted); }

.admin-content {
    padding: 32px;
    max-width: 1320px;
    width: 100%;
    margin: 0 auto; /* Sin margin-top auto para que quede pegado al topbar */
}

/* --- Componentes de Tabla, Tarjetas y Botones --- */
.page-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 24px; }
.page-head__title { font-family: var(--font-serif); font-size: 32px; font-weight: 700; }

.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.stat-card {
    background-color: var(--surface-white);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-md);
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}
.stat-card__value { font-family: var(--font-serif); font-size: 28px; font-weight: 700; margin-top: 6px; }
.stat-card__label { font-size: 12px; color: var(--text-muted); }

.toolbar-card {
    background-color: var(--surface-white);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-md);
    padding: 16px;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.input-control, .select-control {
    height: 38px;
    padding: 0 14px;
    border-radius: 10px;
    border: 1px solid var(--border-soft);
    background-color: var(--bg-cream);
    font-family: var(--font-sans);
    font-size: 13px;
    color: var(--text-main);
}

.btn {
    height: 38px;
    padding: 0 18px;
    border-radius: var(--radius-pill);
    font-size: 13px;
    font-weight: 600;
    border: 1px solid transparent;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-emerald { background-color: var(--primary-emerald); color: #FFFFFF; }
.btn-emerald:hover:not(:disabled) { background-color: var(--primary-emerald-hover); }
.btn-outline { background-color: var(--surface-white); border-color: var(--border-soft); color: var(--text-main); }
.btn-whatsapp { background-color: #15803D; color: #FFFFFF; }

.table-card {
    background-color: var(--surface-white);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-md);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.admin-table { width: 100%; border-collapse: collapse; text-align: left; }
.admin-table th {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    padding: 14px 18px;
    border-bottom: 1px solid var(--border-soft);
    background-color: var(--bg-cream);
}
.admin-table td { padding: 14px 18px; border-bottom: 1px solid var(--border-soft); vertical-align: middle; }

.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border-radius: var(--radius-pill);
    font-size: 11px;
    font-weight: 600;
}
.badge--pending { background-color: var(--warning-soft); color: var(--warning); }
.badge--prep { background-color: var(--emerald-soft); color: var(--primary-emerald); }
.badge--done { background-color: var(--success-soft); color: var(--success); }
.badge--cancelled { background-color: var(--danger-soft); color: var(--danger); }

/* --- Modal --- */
.modal-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(18, 30, 26, 0.55);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.modal-backdrop.is-open { display: flex; }
.modal-card {
    background: var(--surface-white);
    border-radius: 18px;
    width: 100%;
    max-width: 680px;
    max-height: 90vh;
    overflow-y: auto;
    border: 1px solid var(--border-soft);
}
.modal-head { padding: 20px 24px; border-bottom: 1px solid var(--border-soft); display: flex; justify-content: space-between; align-items: center; }
.modal-body { padding: 24px; }
.modal-foot { padding: 16px 24px; border-top: 1px solid var(--border-soft); background: var(--bg-cream); display: flex; justify-content: flex-end; gap: 10px; }

.admin-shell.is-collapsed .admin-sidebar {
    width: 78px;
}
.admin-shell.is-collapsed .sidebar-brand__copy,
.admin-shell.is-collapsed .sidebar-section-label,
.admin-shell.is-collapsed .sidebar-link span,
.admin-shell.is-collapsed .sidebar-note,
.admin-shell.is-collapsed .sidebar-footer span {
    display: none;
}
.admin-shell.is-collapsed .sidebar-link {
    justify-content: center;
    padding: 0;
}

/* ==========================================================================
   MEJORAS ADMIN: PÍLDORAS, LUPA FIGMA, MODOS DE TONO Y MENÚ CONTEXTUAL
   ========================================================================== */

/* Píldoras de Categorías */
.cat-pills-wrap {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 6px 0;
}
.cat-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: var(--radius-pill);
    border: 1px solid var(--border-soft);
    background-color: var(--bg-cream);
    color: var(--text-main);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    user-select: none;
    transition: all 0.18s ease;
}
.cat-pill:hover {
    border-color: var(--primary-emerald);
}
.cat-pill.is-selected {
    background-color: var(--primary-emerald);
    border-color: var(--primary-emerald);
    color: #FFFFFF;
    font-weight: 600;
}
.cat-pill--add {
    background-color: var(--surface-white);
    border-style: dashed;
    color: var(--primary-emerald);
    font-weight: 600;
}
.cat-pill--add:hover {
    background-color: var(--emerald-soft);
}

/* Sub-formularios inline para crear Marca o Categoría al vuelo */
.inline-QuickCreate {
    display: none;
    margin-top: 10px;
    padding: 14px;
    border-radius: 12px;
    background-color: var(--bg-cream);
    border: 1px solid var(--border-soft);
    flex-direction: column;
    gap: 10px;
}
.inline-QuickCreate.is-open {
    display: flex;
}

/* Círculo de previsualización de Tono (soporta Sólido, Bicolor, Degradado, Arcoíris y Transparente) */
.shade-swatch {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 1px solid rgba(0, 0, 0, 0.18);
    flex-shrink: 0;
    display: inline-block;
    position: relative;
    overflow: hidden;
}
.shade-swatch--sm {
    width: 18px;
    height: 18px;
}
.shade-swatch--transparent {
    background-image:
        linear-gradient(45deg, #ccc 25%, transparent 25%),
        linear-gradient(-45deg, #ccc 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #ccc 75%),
        linear-gradient(-45deg, transparent 75%, #ccc 75%);
    background-size: 8px 8px;
    background-position: 0 0, 0 4px, 4px -4px, -4px 0;
    background-color: #fff;
}
.shade-swatch--rainbow {
    background: conic-gradient(#ff0000, #ff8800, #ffff00, #00cc44, #0088ff, #8800ff, #ff0088, #ff0000);
}

/* Tarjeta de cada fila de tono en el modal */
.shade-row-card {
    border: 1px solid var(--border-soft);
    background-color: var(--bg-cream);
    border-radius: 12px;
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.shade-mode-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.shade-mode-btn {
    padding: 3px 10px;
    border-radius: var(--radius-pill);
    font-size: 11px;
    font-weight: 600;
    border: 1px solid var(--border-soft);
    background: var(--surface-white);
    color: var(--text-muted);
    cursor: pointer;
}
.shade-mode-btn.is-active {
    background: var(--primary-emerald);
    border-color: var(--primary-emerald);
    color: #FFFFFF;
}

/* Lupa estilo Figma para muestreo de color sobre la imagen */
#figma-loupe {
    position: fixed;
    width: 124px;
    height: 124px;
    border-radius: 50%;
    border: 3px solid #FFFFFF;
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.32), 0 0 0 1px rgba(0, 0, 0, 0.15);
    pointer-events: none;
    z-index: 9999;
    display: none;
    overflow: hidden;
    transform: translate(-50%, -50%);
    background: #fff;
}
#figma-loupe canvas {
    width: 100%;
    height: 100%;
    image-rendering: pixelated;
    display: block;
}
#figma-loupe .loupe-center-reticle {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 8px;
    height: 8px;
    transform: translate(-50%, -50%);
    border: 1.5px solid #fff;
    box-shadow: 0 0 0 1px #000;
}
#figma-loupe .loupe-hex-pill {
    position: absolute;
    bottom: 12px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(18, 22, 20, 0.9);
    color: #FFFFFF;
    font-family: monospace;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 999px;
    letter-spacing: 0.04em;
}

/* Botón 3 puntos verticales y Menú Contextual (Clic izquierdo o derecho) */
.kebab-btn {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    cursor: pointer;
}
.kebab-btn:hover {
    background-color: var(--bg-cream);
    border-color: var(--border-soft);
    color: var(--text-main);
}

#valu-context-menu {
    position: fixed;
    z-index: 9999;
    display: none;
    min-width: 175px;
    background: var(--surface-white);
    border: 1px solid var(--border-soft);
    border-radius: 12px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.14);
    padding: 6px;
}
.ctx-menu-item {
    width: 100%;
    border: none;
    background: transparent;
    padding: 8px 12px;
    border-radius: 8px;
    font-family: var(--font-sans);
    font-size: 13px;
    font-weight: 500;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    text-align: left;
}
.ctx-menu-item:hover {
    background-color: var(--bg-cream);
}
.ctx-menu-item--danger {
    color: var(--danger);
}
.ctx-menu-item--danger:hover {
    background-color: var(--danger-soft);
}

/* Grilla de tarjetas para vista Cuadrícula en todos los módulos */
.admin-cards-grid {
    display: none;
    grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
    gap: 16px;
}

/* ==========================================================================
   PUNTO 6: RESPONSIVIDAD COMPLETA PARA VALU-ADMIN (MÓVIL Y TABLET)
   ========================================================================== */
.admin-mobile-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 990;
}

@media (max-width: 1024px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .admin-content {
        padding: 20px;
    }
}

@media (max-width: 768px) {
    .admin-sidebar {
        position: fixed;
        left: -270px;
        top: 0;
        bottom: 0;
        z-index: 1000;
        transition: left 0.25s ease;
        box-shadow: 8px 0 24px rgba(0, 0, 0, 0.15);
    }
    .admin-shell.is-collapsed .admin-sidebar {
        left: 0;
        width: 260px;
    }
    .admin-shell.is-collapsed .sidebar-brand__copy,
    .admin-shell.is-collapsed .sidebar-section-label,
    .admin-shell.is-collapsed .sidebar-link span,
    .admin-shell.is-collapsed .sidebar-note,
    .admin-shell.is-collapsed .sidebar-footer span {
        display: block;
    }
    .admin-shell.is-collapsed .sidebar-link {
        justify-content: flex-start;
        padding: 0 14px;
    }

    .admin-topbar {
        padding: 0 16px;
        height: 60px;
    }
    .admin-content {
        padding: 16px;
    }
    .page-head {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    .page-head__title {
        font-size: 26px;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    .stat-card {
        padding: 14px;
    }
    .stat-card__value {
        font-size: 22px;
    }

    /* Tablas con scroll horizontal fluido en móvil sin superponerse */
    .table-card {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .admin-table {
        min-width: 640px;
    }

    /* Modales y formularios adaptados a pantallas pequeñas */
    .modal-backdrop {
        padding: 10px;
    }
    .modal-card {
        max-height: 92dvh;
        border-radius: 14px;
    }
    .modal-head, .modal-body, .modal-foot {
        padding: 14px 16px;
    }
    .form-row-3cols {
        grid-template-columns: 1fr !important;
    }
}

/* ==========================================================================
   MODAL GRÁFICO DE IMPORTACIÓN EXCEL / CSV + SKELETON SCREEN EN VALU-ADMIN
   ========================================================================== */
.import-rules-banner {
    background-color: var(--emerald-soft);
    border: 1px solid rgba(25, 69, 56, 0.2);
    border-radius: 12px;
    padding: 14px 16px;
}

.import-spec-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}
.import-spec-box {
    border: 1px solid var(--border-soft);
    border-radius: 12px;
    padding: 14px;
    background-color: var(--bg-cream);
}
.import-spec-box__head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-soft);
}
.import-Spec-box__head small {
    font-size: 11px;
    color: var(--text-muted);
}
.import-col-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: 12px;
}
.import-col-list li {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.import-col-list code {
    background: var(--surface-white);
    padding: 1px 6px;
    border-radius: 4px;
    border: 1px solid var(--border-soft);
    font-size: 11px;
}

.import-sample-table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border-soft);
    border-radius: 10px;
}
.import-sample-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
    text-align: left;
    background: var(--surface-white);
}
.import-sample-table th {
    background: var(--bg-cream);
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-soft);
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
}
.import-sample-table th.is-req {
    color: var(--primary-emerald);
    font-weight: 700;
}
.import-sample-table td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-soft);
    white-space: nowrap;
}

.import-dropzone {
    border: 2px dashed var(--primary-emerald);
    background-color: var(--bg-cream);
    border-radius: 14px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    cursor: pointer;
    text-align: center;
    transition: background-color 0.2s;
}
.import-dropzone:hover {
    background-color: var(--emerald-soft);
}

.import-alert {
    padding: 12px 16px;
    border-radius: 10px;
    font-size: 13px;
}
.import-alert--ok {
    background-color: var(--success-soft);
    color: #14532D;
    border: 1px solid rgba(21, 128, 61, 0.25);
}
.import-alert--error {
    background-color: var(--danger-soft);
    color: var(--danger);
    border: 1px solid rgba(185, 28, 28, 0.25);
}

/* Skeleton Screen en valu-admin */
@keyframes valuShimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}
.sk-box {
    background: linear-gradient(90deg, #EAE8E1 25%, #F4F2EC 50%, #EAE8E1 75%);
    background-size: 200% 100%;
    animation: valuShimmer 1.3s infinite linear;
}
.admin-skeleton-overlay {
    display: none;
    padding: 32px;
    max-width: 1320px;
    width: 100%;
    margin: 0 auto;
}
.admin-skeleton-overlay.is-visible {
    display: block;
}
.admin-skeleton-overlay.is-visible ~ main.admin-content {
    display: none;
}

@media (max-width: 768px) {
    .import-spec-grid {
        grid-template-columns: 1fr;
    }
    .admin-skeleton-overlay {
        padding: 16px;
    }
}

/* ==========================================================================
   PUNTO 2 Y PUNTO 5: SWATCH BICOLOR LIMPIO Y COLUMNAS AMPLIAS EN UNA SOLA LÍNEA
   ========================================================================== */
.shade-swatch {
    border: none !important;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.16);
    background-origin: border-box !important;
    background-clip: border-box !important;
}

/* Evitar que Estado ("Sin confirmar") y Entrega ("Retiro en tienda") se partan en 2 o 3 líneas (Imágenes 5 y 6) */
.badge {
    white-space: nowrap !important;
    flex-shrink: 0;
}

.admin-table th,
.admin-table td {
    white-space: nowrap;
}

/* Permitir que Nombre, Categoría y Marca tengan buen ancho mínimo en móvil sin apilarse */
.admin-table td:nth-child(1) {
    min-width: 230px;
    white-space: normal;
}
.admin-table td:nth-child(2) {
    min-width: 170px;
    white-space: normal;
}
.admin-table td:nth-child(3) {
    min-width: 140px;
    white-space: nowrap;
}

@media (max-width: 768px) {
    .admin-table {
        min-width: 780px;
    }
}

/* ==========================================================================
   PUNTO 3: COLUMNA ORDEN COMPACTA
   ========================================================================== */
.orders-table th:first-child,
.orders-table td:first-child {
    min-width: 135px !important;
    width: auto !important;
    max-width: none !important;
    white-space: nowrap !important;
}

/* ==========================================================================
   PUNTO 4: MODO OSCURO COMPLETO Y PERSISTENTE EN ADMIN
   ========================================================================== */
body.dark-mode {
    --bg-cream: #121715;
    --surface-white: #1A221F;
    --emerald-soft: #233830;
    --text-main: #F3F2EE;
    --text-muted: #9BA19E;
    --border-soft: #2A3531;
}

body.dark-mode .sidebar-link.is-active {
    background-color: var(--primary-emerald);
    color: #FFFFFF;
}

body.dark-mode .input-control,
body.dark-mode .select-control,
body.dark-mode .shade-row-card input.js-shade-name {
    background-color: #141A18 !important;
    color: var(--text-main) !important;
    border-color: var(--border-soft) !important;
}

body.dark-mode .btn-outline {
    background-color: #1A221F;
    border-color: var(--border-soft);
    color: var(--text-main);
}
body.dark-mode .btn-outline:hover {
    background-color: #242F2B;
}

body.dark-mode .badge--pending {
    background-color: rgba(245, 158, 11, 0.18);
    color: #FBBF24;
}
body.dark-mode .badge--prep {
    background-color: rgba(25, 69, 56, 0.45);
    color: #6EE7B7;
}
body.dark-mode .badge--done {
    background-color: rgba(21, 128, 61, 0.25);
    color: #4ADE80;
}
body.dark-mode .badge--cancelled {
    background-color: rgba(185, 28, 28, 0.25);
    color: #F87171;
}

/* ==========================================================================
   1. TARJETAS DE ESTADÍSTICAS CLICKEABLES (FILTRO DE STOCK)
   ========================================================================== */
.stat-card--clickable {
    cursor: pointer;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.15s ease;
    user-select: none;
}
.stat-card--clickable:hover {
    border-color: var(--primary-emerald);
    transform: translateY(-2px);
}
.stat-card--clickable.is-filter-active {
    border-color: var(--primary-emerald);
    box-shadow: 0 0 0 2px var(--emerald-soft);
}

/* ==========================================================================
   2. PERFIL DE USUARIO EN LA PARTE INFERIOR DEL SIDEBAR
   ========================================================================== */
.sidebar-profile {
    padding: 12px 14px;
    border-top: 1px solid var(--border-soft);
    display: flex;
    align-items: center;
    gap: 10px;
    background-color: var(--surface-white);
    cursor: context-menu;
}
.sidebar-profile__info {
    flex: 1;
    min-width: 0;
}
.sidebar-profile__info .admin-user-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sidebar-profile__actions {
    display: flex;
    align-items: center;
    gap: 2px;
    flex-shrink: 0;
}
.sidebar-profile .admin-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

/*=============================================================*/

.sidebar-profile__info .admin-user-email {
    font-size: 11px;
    color: var(--text-muted);
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Ajuste cuando el sidebar está contraído SOLO en escritorio */
@media (min-width: 769px) {
    .admin-shell.is-collapsed .sidebar-profile {
        flex-direction: column;
        padding: 12px 8px;
        gap: 8px;
    }
    .admin-shell.is-collapsed .sidebar-profile__info,
    .admin-shell.is-collapsed .js-profile-kebab {
        display: none;
    }
}

/* En móvil: mostrar overlay al abrir el sidebar y mantener el perfil igual que en escritorio */
@media (max-width: 768px) {
    .admin-shell.is-collapsed .admin-mobile-overlay {
        display: block;
    }
    .admin-shell.is-collapsed .sidebar-profile {
        flex-direction: row;
        padding: 12px 14px;
        gap: 10px;
    }
    .admin-shell.is-collapsed .sidebar-profile__info {
        display: block;
    }
    .admin-shell.is-collapsed .js-profile-kebab {
        display: inline-flex;
    }
}


/*=============================================================*/

/* Menú contextual del perfil (mismo estilo que #valu-context-menu) */
#valu-profile-context-menu {
    position: fixed;
    z-index: 9999;
    display: none;
    min-width: 185px;
    background: var(--surface-white);
    border: 1px solid var(--border-soft);
    border-radius: 12px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18);
    padding: 6px;
}

/* ==========================================================================
   3. SKELETON SCREEN EN MODO OSCURO
   ========================================================================== */
body.dark-mode .sk-box {
    background: linear-gradient(90deg, #1A221F 25%, #24302C 50%, #1A221F 75%);
    background-size: 200% 100%;
}
/* Estado vacío para tablas y cuadrículas */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 6px;
    padding: 44px 20px;
    color: var(--text-muted);
}
.empty-state i {
    font-size: 36px;
    color: var(--accent-camel);
    opacity: 0.85;
}
.empty-state__title {
    font-family: var(--font-serif);
    font-size: 17px;
    font-weight: 600;
    color: var(--text-main);
}
.empty-state__desc {
    font-size: 13px;
    color: var(--text-muted);
}
.empty-state--card {
    grid-column: 1 / -1;
    background-color: var(--surface-white);
    border: 1px dashed var(--border-soft);
    border-radius: var(--radius-md);
}

/* Scroll interno en el sidebar y bloqueo del fondo en móvil */
.admin-sidebar {
    height: 100dvh;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

@media (max-width: 768px) {
    html.sidebar-scroll-lock,
    body.sidebar-scroll-lock {
        overflow: hidden !important;
        height: 100dvh;
        overscroll-behavior: none;
    }
}

/* Input de búsqueda con lupa integrada */
.search-input-group {
    position: relative;
    display: flex;
    align-items: center;
    flex: 1;
    min-width: 240px;
}
.search-input-group .input-control {
    width: 100%;
    padding-right: 40px;
}
.search-input-group__btn {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    width: 30px;
    height: 30px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 17px;
    cursor: pointer;
    transition: color 0.15s ease, background-color 0.15s ease;
}
.search-input-group__btn:hover {
    color: var(--primary-emerald);
    background-color: var(--emerald-soft);
}

/* Banner de error para nombres duplicados */
.alert-banner {
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 18px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.alert-banner--error {
    background-color: var(--danger-soft);
    color: var(--danger);
    border: 1px solid rgba(185, 28, 28, 0.22);
}

/* Botón de filtros móvil y panel desplegable */
.btn-filter-toggle {
    display: none;
    position: relative;
    width: 38px;
    height: 38px;
    padding: 0;
    justify-content: center;
    flex-shrink: 0;
}
.btn-filter-toggle .filter-active-dot {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background-color: var(--primary-emerald);
}

/* Escritorio: ordenamiento junto al buscador en Productos y demás filtros debajo */
@media (min-width: 769px) {
    .filterbar-panel {
        display: flex;
        gap: 8px;
        flex-wrap: wrap;
        align-items: center;
    }
    .toolbar-card--products .filterbar-panel {
        display: contents;
    }
    .toolbar-card--products .search-input-group {
        order: 1;
        flex: 1;
        min-width: 220px;
    }
    .toolbar-card--products .filterbar-sort {
        order: 2;
        display: flex;
        align-items: center;
        gap: 8px;
        flex-shrink: 0;
    }
    .toolbar-card--products .filterbar-extras {
        order: 3;
        flex-basis: 100%;
        display: grid;
        grid-template-columns: repeat(5, minmax(0, 1fr));
        gap: 8px;
        width: 100%;
    }
    .toolbar-card--products .filterbar-extras .select-control {
        width: 100%;
        min-width: 0;
    }
}

/* Móvil: ocultar filtros detrás del botón con icono */
@media (max-width: 768px) {
    .toolbar-card {
        gap: 10px;
    }
    .search-input-group {
        flex: 1;
        min-width: 0;
    }
    .btn-filter-toggle {
        display: inline-flex;
    }
    .filterbar-panel {
        display: none;
        flex-basis: 100%;
        flex-direction: column;
        gap: 10px;
        padding-top: 12px;
        border-top: 1px solid var(--border-soft);
    }
    .toolbar-card.is-filters-open .filterbar-panel {
        display: flex;
    }
    .filterbar-sort,
    .filterbar-extras {
        display: flex;
        flex-direction: column;
        gap: 10px;
        width: 100%;
    }
    .filterbar-panel .select-control,
    .filterbar-panel .btn {
        width: 100%;
        justify-content: center;
    }
}

.admin-topbar {
    position: sticky;
    top: 0;
    z-index: 500;
    height: 72px;
    background-color: var(--surface-white);
    border-bottom: 1px solid var(--border-soft);
    padding: 0 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* Contenedor de acciones en page-head y topbar sticky */
.page-head__actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}
.topbar-sticky-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}
.topbar-sticky-actions .page-head__actions {
    gap: 8px;
    flex-wrap: nowrap;
}

/* Interruptor Lista / Cuadrícula estilo iOS */
.gdrive-view-switch {
    display: inline-flex;
    align-items: center;
    padding: 3px;
    background-color: var(--bg-cream);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-pill);
    gap: 2px;
}
.gdrive-view-btn {
    width: 34px;
    height: 30px;
    border: none;
    border-radius: var(--radius-pill);
    background: transparent;
    color: var(--text-muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 17px;
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}
.gdrive-view-btn:hover:not(.is-active) {
    color: var(--text-main);
}
.gdrive-view-btn.is-active {
    background-color: var(--primary-emerald);
    color: #FFFFFF;
    box-shadow: 0 2px 6px rgba(25, 69, 56, 0.25);
}

/* En móvil: botones de Importar y Agregar solo con iconos */
@media (max-width: 768px) {
    .btn-icon-mobile {
        width: 38px;
        height: 38px;
        padding: 0;
        justify-content: center;
        font-size: 18px;
    }
    .btn-icon-mobile .btn-label {
        display: none;
    }
    .topbar-sticky-actions .gdrive-view-switch {
        padding: 2px;
    }
    .topbar-sticky-actions .gdrive-view-btn {
        width: 30px;
        height: 28px;
        font-size: 15px;
    }
    .topbar-sticky-actions .btn-icon-mobile {
        width: 34px;
        height: 34px;
    }
}

.page-head__actions {
    margin-left: auto;
    justify-content: flex-end;
}

@media (max-width: 1024px) {
    .btn-icon-mobile {
        width: 38px;
        height: 38px;
        padding: 0;
        justify-content: center;
        font-size: 18px;
    }
    .btn-icon-mobile .btn-label {
        display: none;
    }
}

@media (max-width: 768px) {
    .page-head {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }
    .page-head__actions {
        width: 100%;
        justify-content: flex-end;
    }
}

.bx-log-out {
    display: inline-block;
    transform: scaleX(-1);
}

.sidebar-brand__logo {
    height: 36px;
    width: auto;
    max-width: 190px;
    object-fit: contain;
}
.sidebar-brand__logo--dark,
.sidebar-brand__logo-icon {
    display: none;
}
body.dark-mode .sidebar-brand__logo--light {
    display: none;
}
body.dark-mode .sidebar-brand__logo--dark {
    display: block;
}
@media (min-width: 769px) {
    .admin-shell.is-collapsed .sidebar-brand {
        padding: 0;
        justify-content: center;
    }
    .admin-shell.is-collapsed .sidebar-brand__logo--light,
    .admin-shell.is-collapsed .sidebar-brand__logo--dark {
        display: none;
    }
    .admin-shell.is-collapsed .sidebar-brand__logo-icon {
        display: block;
        width: 38px;
        height: auto;
    }
}