/* ====== SIDEBAR ====== */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    height: 100vh;
    height: 100dvh;
    width: 0;
    background: linear-gradient(180deg, var(--dark-green), var(--primary-green));
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    transition: width 0.3s ease;
    z-index: 2000;
    box-shadow: 2px 0 10px rgba(0,0,0,0.2);
}

.sidebar.open {
    width: 320px;
}

.closebtn {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: none;
    border: none;
    color: var(--white);
    font-size: 2rem;
    cursor: pointer;
    z-index: 10;
}

/* ====== NAV PRINCIPAL ====== */
.nav-principal {
    padding: 2rem 1rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.nav-principal a {
    display: flex;
    align-items: center;
    color: #ffffff;
    text-decoration: none;
    padding: 16px 20px;
    margin: 0 8px;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.08);
    transition: background 0.2s, transform 0.15s;
    min-height: 54px;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
}

.nav-principal a:hover,
.nav-principal a:active {
    background: rgba(255, 255, 255, 0.22);
}

.nav-principal a:active {
    transform: scale(0.98);
}

/* Estilo especial para Editar lista / Facturar */
.sidebar-admin-link {
    background: rgba(255, 255, 255, 0.15) !important;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.sidebar-admin-link:hover,
.sidebar-admin-link:active {
    background: rgba(255, 255, 255, 0.28) !important;
}

.sidebar h3 {
    color: #f7f7f7;
    padding: 1rem;
    margin: 1rem 0;
    border-bottom: 2px solid #a5d6a7;
    font-size: 1.1rem;
}

/* ====== CATEGORÍAS Y SUBMENÚS ====== */
.categoria {
    margin-bottom: 0.5rem;
}

.categoria-btn {
    width: 100%;
    background: rgba(255,255,255,0.1);
    border: none;
    color: var(--white);
    text-align: left;
    padding: 1rem 1.5rem;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s;
    border-left: 4px solid transparent;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.categoria-btn:hover {
    background: rgba(255,255,255,0.2);
    border-left-color: var(--accent-orange);
}

.categoria-btn::after {
    content: '▼';
    font-size: 0.8rem;
    transition: transform 0.3s;
}

.categoria-btn.active::after {
    transform: rotate(180deg);
}

.submenu {
    background: rgba(0,0,0,0.2);
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.submenu.open {
    max-height: 500px;
    overflow-y: auto;
    overflow-x: hidden;
}

.submenu.open::-webkit-scrollbar {
    width: 6px;
}

.submenu.open::-webkit-scrollbar-track {
    background: rgba(255,255,255,0.1);
    border-radius: 10px;
}

.submenu.open::-webkit-scrollbar-thumb {
    background: #a5d6a7;
    border-radius: 10px;
}

.submenu.open::-webkit-scrollbar-thumb:hover {
    background: #4caf50;
}

.submenu a {
    display: block;
    color: #fafdfb;
    text-decoration: none;
    padding: 0.8rem 2rem;
    font-size: 0.9rem;
    border-left: 3px solid transparent;
    transition: all 0.3s;
}

.submenu a:hover {
    background: rgba(255,255,255,0.1);
    border-left-color: #4caf50;
    padding-left: 2.5rem;
}

/* ============================================================ */
/* Toggle Modo Admin en el sidebar                               */
/* ============================================================ */
.sidebar-toggle-admin {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 10px 12px 14px;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    color: #ffffff;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    width: calc(100% - 24px);
    text-align: left;
    transition: background 0.2s;
    touch-action: manipulation;
}

.sidebar-toggle-admin:hover {
    background: rgba(255, 255, 255, 0.15);
}

.sidebar-toggle-admin-label {
    display: flex;
    align-items: center;
    gap: 8px;
}

.sidebar-toggle-admin-switch {
    position: relative;
    width: 46px;
    height: 26px;
    background: #9ca3af;
    border-radius: 999px;
    transition: background 0.25s;
    flex-shrink: 0;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.15);
}

.sidebar-toggle-admin-switch::before {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 20px;
    height: 20px;
    background: #ffffff;
    border-radius: 50%;
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.sidebar-toggle-admin.switch-on .sidebar-toggle-admin-switch {
    background: #22c55e;
}

.sidebar-toggle-admin.switch-on .sidebar-toggle-admin-switch::before {
    transform: translateX(20px);
}

/* ============================================================ */
/* Toggles de Preview (Ver como Tienda / Ver como Minorista)     */
/* ============================================================ */
.sidebar-toggle-preview {
    margin-top: -6px;
}

/* Tienda = azul (simula precio mayorista) */
.sidebar-toggle-tienda.switch-on .sidebar-toggle-admin-switch {
    background: #3b82f6;
}

.sidebar-toggle-tienda.switch-on {
    background: rgba(59, 130, 246, 0.18);
}

/* Minorista = púrpura (simula precio de menudeo) */
.sidebar-toggle-minorista.switch-on .sidebar-toggle-admin-switch {
    background: #8b5cf6;
}

.sidebar-toggle-minorista.switch-on {
    background: rgba(139, 92, 246, 0.18);
}

/* ============================================================ */
/* Link de Ofertas en el sidebar                                 */
/* ============================================================ */
.sidebar-ofertas-link {
    display: flex;
    align-items: center;
    margin: 10px 12px;
    padding: 14px 20px;
    background: linear-gradient(135deg, #f97316 0%, #ea580c 100%);
    color: #ffffff !important;
    text-decoration: none;
    font-size: 1rem;
    font-weight: 700;
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(249, 115, 22, 0.35);
    transition: transform 0.15s, box-shadow 0.15s;
    touch-action: manipulation;
    justify-content: center;
    letter-spacing: 0.02em;
}

.sidebar-ofertas-link:hover,
.sidebar-ofertas-link:active {
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(249, 115, 22, 0.5);
}

.sidebar-ofertas-link:active {
    transform: translateY(0);
}