* { box-sizing: border-box; margin: 0; padding: 0; font-family: -apple-system, sans-serif; }

/* EL ESCUDO ANTI-DESBORDAMIENTO GLOBAL */
html, body {
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
}

body { background-color: #f4f6f8; color: #333; display: flex; flex-direction: row; }

.sidebar { width: 250px; background: #1a1a1a; color: #fff; min-height: 100vh; padding: 20px; }
.sidebar h2 { font-size: 18px; margin-bottom: 30px; color: #EB641E; text-align: center; letter-spacing: 1px;}

.nav-menu { list-style: none; }
.nav-menu li { margin-bottom: 10px; }
.nav-menu a { display: block; padding: 12px 15px; color: #ccc; text-decoration: none; border-radius: 6px; transition: 0.2s; font-size: 15px; cursor: pointer;}
.nav-menu a:hover { background: #333; color: #fff; }
.nav-menu a.active { background: #EB641E; color: #fff; font-weight: bold; }

/* REGLA CRUCIAL PARA LA COLUMNA DERECHA */
.main-content {
    flex: 1;
    padding: 30px;
    min-width: 0;
    max-width: 100%;
    overflow-x: hidden;
}

/* REGLA CRUCIAL PARA LAS TARJETAS */
.panel-card {
    background: #fff;
    padding: 25px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    min-width: 0;
    overflow: hidden;
    word-wrap: break-word;
}

.admin-section { display: none; }
.admin-section.active { display: block; }

.table-pedidos { width: 100%; border-collapse: collapse; margin-top: 15px; }
.table-pedidos th { background-color: #f8f9fa; padding: 12px; text-align: left; font-size: 13px; color: #666; border-bottom: 2px solid #ddd; }
.table-pedidos td { padding: 12px; border-bottom: 1px solid #eee; font-size: 14px; vertical-align: middle; }

.badge { padding: 5px 10px; border-radius: 20px; font-size: 11px; font-weight: bold; color: #fff; }
.bg-pendiente { background-color: #ffc107; color: #333; }
.bg-confirmado { background-color: #28a745; }

.btn-action { padding: 8px 12px; border: none; border-radius: 4px; font-size: 12px; cursor: pointer; font-weight: bold; transition: 0.2s; margin-right: 5px; }
.btn-confirm { background-color: #28a745; color: white; }
.btn-pdf { background-color: #EB641E; color: white; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 20px; }
.form-group { display: flex; flex-direction: column; min-width: 0; }
.form-group label { font-size: 13px; font-weight: bold; margin-bottom: 6px; }

/* PROTECCIÓN DE INPUTS EN CELULARES */
.form-group input, .form-group textarea, .form-group select {
    width: 100%;
    max-width: 100%;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 14px;
}

.full-width { grid-column: span 2; }

.gallery-preview { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 10px; }
.gallery-preview img { width: 85px; height: 85px; object-fit: cover; border-radius: 6px; border: 2px solid transparent; cursor: pointer; opacity: 0.5; transition: 0.2s; }
.gallery-preview img.selected { border: 3px solid #EB641E; opacity: 1; transform: scale(1.05); }

.btn-save { background: #28a745; color: #fff; border: none; padding: 14px 24px; font-weight: bold; border-radius: 6px; cursor: pointer; font-size: 15px; }
.btn-new { background: #EB641E; color: #fff; border: none; padding: 12px 20px; font-weight: bold; border-radius: 6px; cursor: pointer; font-size: 14px; }

.section-title { font-size: 16px; margin-bottom: 15px; border-bottom: 2px solid #eee; padding-bottom: 5px; color: #666; }
.filtros-container { background: #f9f9f9; padding: 20px; border-radius: 8px; margin-bottom: 20px; border: 1px solid #eee; }

.modal-overlay { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.6); z-index: 1000; align-items: center; justify-content: center; backdrop-filter: blur(3px); }
.modal-content-box { background: #fff; width: 90%; max-width: 750px; border-radius: 10px; padding: 30px; max-height: 90vh; overflow-y: auto; box-shadow: 0 10px 30px rgba(0,0,0,0.2); position: relative; }
.modal-close { position: absolute; top: 20px; right: 25px; font-size: 28px; cursor: pointer; color: #666; transition: 0.2s; }
.modal-close:hover { color: #d9534f; }

/* CONTENEDOR PARA TABLAS SIN ROMPER LA PÁGINA */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 15px;
}

/* REGLA CRÍTICA PARA QUE CHART.JS NO ROMPA LA PANTALLA MÓVIL */
canvas {
    max-width: 100% !important;
    height: auto !important;
}

/* =========================================
   DISEÑO RESPONSIVO (MÓVILES Y TABLETS)
   ========================================= */
@media (max-width: 992px) {
    body { flex-direction: column; }
    .sidebar { width: 100%; min-height: auto; padding: 15px; }
    .main-content { padding: 15px; }

    /* Forzamos a que todos los grids bajen a 1 sola columna */
    .form-grid { grid-template-columns: 1fr !important; }
    .full-width { grid-column: span 1 !important; }
    .charts-grid { grid-template-columns: 1fr !important; }

    /* Override para los grids insertados directamente en el HTML */
    div[style*="grid-template-columns: repeat"] {
        grid-template-columns: 1fr !important;
    }
}

/* ============================================================================
   ESTILOS EXCLUSIVOS DEL PUNTO DE VENTA (POS)
   ============================================================================ */

.pos-body { background: #f0f2f5; height: 100vh; overflow: hidden; display: flex; flex-direction: column; margin: 0; }
.pos-header { background: #1a1a1a; color: white; padding: 15px 20px; display: flex; justify-content: space-between; align-items: center; box-shadow: 0 2px 10px rgba(0,0,0,0.1); z-index: 10; }
.pos-header-left { display:flex; align-items:center; gap:15px; }
.pos-title { margin:0; font-size:22px; color:#17a2b8; }
.pos-title span { color:white; }
.pos-badge-caja { background:#28a745; padding:4px 8px; border-radius:4px; font-size:12px; font-weight:bold; }
.pos-header-right { display:flex; align-items:center; gap:20px; }
.pos-user-info { font-size:14px; font-weight:bold; }

.btn-pos-danger { background:#dc3545; color:white; border:none; padding:8px 15px; border-radius:4px; cursor:pointer; font-weight:bold; }
.btn-pos-dark { background:#333; color:white; border:none; padding:8px 15px; border-radius:4px; cursor:pointer; }
.btn-pos-info { background:#17a2b8; color:white; border:none; border-radius:4px; cursor:pointer; font-size:12px; padding:2px 8px; }
.btn-pos-success { background:#28a745; color:white; border:none; padding:12px; border-radius:4px; font-weight:bold; cursor:pointer; }
.btn-pos-cancel { background:#666; color:white; border:none; padding:12px 20px; border-radius:4px; font-weight:bold; cursor:pointer; }
.btn-pos-remove { background:none; border:none; color:#dc3545; font-size:11px; cursor:pointer; font-weight:bold; }

.pos-container { display: flex; flex: 1; overflow: hidden; }

/* PANEL IZQUIERDO POS */
.pos-left { flex: 2; display: flex; flex-direction: column; background: #fff; border-right: 1px solid #ddd; }
.scanner-box { padding: 15px 20px; background: #fff; border-bottom: 1px solid #eee; display: flex; flex-direction: column; gap: 10px; }
.pos-pistola { width: 100%; font-size: 18px; padding: 12px; border: 2px solid #17a2b8; border-radius: 6px; outline: none; }
.pos-manual-search { display: flex; gap: 10px; }
.pos-manual-search input, .pos-manual-search select { padding: 10px; border: 1px solid #ccc; border-radius: 4px; font-size: 14px; outline: none; flex: 1; }

.products-grid-container { flex: 1; overflow-y: auto; padding: 20px; background: #f8f9fa; }
.pos-product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 15px; }
.pos-product-card { background: #fff; border: 1px solid #e0e0e0; border-radius: 8px; overflow: hidden; cursor: pointer; transition: 0.2s; position: relative; display: flex; flex-direction: column; }
.pos-product-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.1); border-color: #17a2b8; transform: translateY(-2px); }
.pos-product-card img { width: 100%; height: 120px; object-fit: cover; border-bottom: 1px solid #eee; }
.pos-product-card .info { padding: 10px; flex: 1; display: flex; flex-direction: column; justify-content: space-between; }
.pos-product-card .name { font-size: 13px; color: #333; font-weight: bold; margin-bottom: 5px; line-height: 1.2; }
.pos-product-card .price { font-size: 15px; color: #EB641E; font-weight: 900; }
.pos-product-card .stock-badge { position: absolute; top: 5px; left: 5px; background: #28a745; color: white; padding: 2px 6px; border-radius: 4px; font-size: 11px; font-weight: bold; }
.pos-product-card .oferta-badge { position: absolute; top: 5px; right: 5px; background: #dc3545; color: white; padding: 2px 6px; border-radius: 4px; font-size: 11px; font-weight: bold; }
.pos-product-card.agotado { opacity: 0.6; filter: grayscale(100%); cursor: not-allowed; }

/* PANEL DERECHO POS */
.pos-right { flex: 1; background: #fff; display: flex; flex-direction: column; min-width: 380px; max-width: 450px; }
.box-panel { padding: 15px 20px; border-bottom: 1px solid #eee; }
.box-panel.bg-light { background: #f8f9fa; }
.box-panel-header { display:flex; justify-content:space-between; align-items:center; margin-bottom:8px; }
.box-panel-header label { font-size:12px; font-weight:bold; color:#666; }

.pos-relative { position: relative; }
.pos-input-search { width:100%; padding:10px; border:1px solid #ccc; border-radius:4px; font-size:13px; outline:none; }
.dropdown-list { display: none; position: absolute; top: 100%; left: 0; width: 100%; background: white; border: 1px solid #ccc; max-height: 200px; overflow-y: auto; z-index: 100; box-shadow: 0 4px 10px rgba(0,0,0,0.15); }
.dropdown-item { padding: 10px; border-bottom: 1px solid #eee; cursor: pointer; }
.dropdown-item:hover { background: #f8f9fa; }

.pos-cliente-selected { display:flex; justify-content:space-between; align-items:center; margin-top:8px; }
.pos-cliente-selected p { margin:0; font-weight:bold; color:#888; font-size:13px; }

/* TABLA POS */
.cart-table-container { flex: 1; overflow-y: auto; padding: 0; background: #fafafa; }
.pos-table { width: 100%; border-collapse: collapse; }
.pos-table th { background: #f1f1f1; padding: 12px; text-align: left; position: sticky; top: 0; z-index: 5; font-size: 13px; color: #666; }
.pos-table td { padding: 10px 12px; border-bottom: 1px solid #eee; font-size: 13px; vertical-align: middle; }
.pos-empty-cart { text-align:center; color:#888; padding:30px; }
.text-center { text-align: center; }
.text-right { text-align: right; }

/* ZONA DE COBRO POS */
.pos-label-block { font-size:12px; font-weight:bold; color:#666; display:block; margin-bottom:5px; }
.pos-select-pago { width:100%; padding:10px; border:1px solid #ccc; border-radius:4px; font-size:14px; font-weight:bold; outline:none; margin-bottom:15px; }
.pos-total-section { text-align:right; border-bottom: 1px solid #ddd; padding-bottom: 10px; margin-bottom: 10px; }
.pos-total-section p:first-child { margin:0 0 2px 0; font-size:12px; color:#666; font-weight:bold; }
.pos-total-section p:last-child { margin:0; font-size:38px; font-weight:900; color:#dc3545; letter-spacing:-1px; }

.pos-pago-row { display:flex; justify-content:space-between; align-items:center; margin-bottom:10px; }
.pos-pago-row label { font-size:13px; font-weight:bold; color:#666; }
.pos-input-monto { width:100px; padding:8px; border:1px solid #ccc; border-radius:4px; font-size:16px; font-weight:bold; text-align:right; outline:none; }
.pos-vuelto-val { font-size:24px; font-weight:900; color:#28a745; }

.btn-cobrar { background: #28a745; color: white; border: none; width: 100%; padding: 20px; font-size: 22px; font-weight: 900; border-radius: 0; cursor: pointer; transition: 0.2s; }
.btn-cobrar:hover { background: #218838; }
.btn-cobrar:disabled { background: #ccc; cursor: not-allowed; }

/* MODALES POS (NUEVO CLIENTE / CAJA) */
.pos-modal-overlay { display:none; position:fixed; top:0; left:0; width:100%; height:100%; background:rgba(0,0,0,0.6); z-index:1000; align-items:center; justify-content:center; backdrop-filter: blur(3px); }
.pos-modal-dark { background:rgba(0,0,0,0.9); z-index:2000; backdrop-filter: blur(5px); }
.pos-modal-darker { background:rgba(0,0,0,0.8); z-index:2000; }
.pos-modal-content { background:white; padding:25px; border-radius:8px; width:90%; max-width:400px; box-shadow: 0 10px 25px rgba(0,0,0,0.2); }
.pos-modal-title { margin-top:0; border-bottom: 2px solid #eee; padding-bottom: 10px; }
.pos-modal-desc { color:#666; font-size:14px; margin-bottom:25px; }

.pos-form-group { margin-bottom:12px; }
.pos-form-group label { display:block; font-weight:bold; color:#333; margin-bottom:10px; }
.pos-form-group input { width:100%; padding:12px; border:1px solid #ccc; border-radius:4px; }
.pos-input-caja { padding:15px; border:2px solid #ccc; border-radius:6px; font-size:24px; text-align:center; font-weight:bold; outline:none; }
.pos-input-caja.border-red { border-color: #dc3545; }

.margin-bottom-lg { margin-bottom: 20px; }
.pos-modal-actions { display:flex; gap:10px; }
.full-width-btn { flex:1; }

/* Helpers de Color Tipográfico POS */
.text-orange { color: #EB641E; }
.text-green { color: #28a745; }
.text-red { color: #dc3545; }

/* ============================================================================
   ESTILOS EXCLUSIVOS DEL LOGIN (ADMIN/POS)
   ============================================================================ */

.login-body {
    background-color: #f4f6f8;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    margin: 0;
}

.login-card {
    background: #fff;
    padding: 40px;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
    width: 100%;
    max-width: 400px;
}

.login-card h2 {
    text-align: center;
    color: #1a1a1a;
    margin-bottom: 30px;
    font-size: 24px;
    letter-spacing: 1px;
}

.login-card h2 span { color: #EB641E; }

.login-input {
    width: 100%;
    padding: 12px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 14px;
    outline: none;
    transition: 0.2s;
}

.login-input:focus { border-color: #EB641E; }

.btn-login {
    width: 100%;
    background: #EB641E;
    color: white;
    border: none;
    padding: 14px;
    border-radius: 6px;
    font-weight: bold;
    cursor: pointer;
    font-size: 15px;
    margin-top: 10px;
    transition: background 0.3s;
}

.btn-login:hover { background: #d35400; }

/* ============================================================================
   ESTILOS EXCLUSIVOS DEL PANEL DE ADMINISTRACIÓN (admin.html)
   ============================================================================ */

/* Navegación y Sidebar */
.nav-pos-link { color: #28a745; font-weight: bold; cursor: pointer; }
.nav-item-pos { margin-bottom: 15px; }
.nav-btn-pos { background: #17a2b8; color: white; font-weight: bold; text-align: center; border-radius: 6px; padding: 10px; }
.nav-divider-top { margin-top: 40px; border-top: 1px solid #333; padding-top: 10px; }
.nav-logout-link { color: #d9534f; cursor: pointer; }

/* Títulos y Encabezados */
.admin-header-title { margin-bottom: 20px; }
.admin-header-title-sm { margin-bottom: 10px; }
.admin-header-actions { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; margin-bottom: 20px; gap: 10px; }
.admin-header-btn-group { display: flex; gap: 10px; flex-wrap: wrap; }
.chart-title { color: #666; font-size: 15px; margin-bottom: 15px; }
.config-subtitle { border-bottom: 1px solid #ccc; padding-bottom: 5px; color: #666; font-size: 15px; }

/* Filtros */
.filter-label-title { font-size: 13px; color: #666; margin-bottom: 10px; font-weight: bold; }
.form-grid-filters { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); align-items: end; margin-bottom: 15px; }
.btn-filter-apply { height: 42px; }

/* Tarjetas KPI (Dashboard) */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 20px; margin-top: 20px; }
.kpi-card { border-left: 5px solid transparent; }
.border-success { border-left-color: #28a745; }
.border-orange { border-left-color: #EB641E; }
.border-info { border-left-color: #17a2b8; }
.border-primary { border-left-color: #007bff; }
.border-danger { border-left-color: #dc3545; }
.border-purple { border-left-color: #6f42c1; }
.border-warning { border-left-color: #fd7e14; }

.bg-primary-light { background: #f4f8ff; }
.bg-danger-light { background: #fff4f5; }
.bg-purple-light { background: #f8f4ff; }
.bg-warning-light { background: #fff7f0; }

.kpi-title { color: #666; font-size: 14px; }
.kpi-value { font-size: 28px; font-weight: bold; color: #333; margin-top: 10px; }
.kpi-value-sm { font-size: 16px; font-weight: bold; color: #333; margin-top: 10px; }

/* Gráficos */
.charts-grid-layout { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; margin-top: 25px; }

/* Utilidades de Texto y Botones Extras */
.text-center { text-align: center; }
.btn-secondary { background-color: #6c757d; color: white; }
.btn-info { background-color: #17a2b8; color: white; }
.btn-primary { background-color: #EB641E; color: white; }
.btn-dark { background-color: #343a40; color: white; }
.btn-cancel { background: #666; color: white; }
.btn-cancel-light { background: #ccc; color: #333; }
.btn-md { padding: 12px 20px; font-size: 14px; }

/* Formularios de Administración */
.admin-form-container { background: #fafafa; padding: 25px; border-radius: 8px; margin-top: 20px; }
.admin-form-box { background: #f9f9f9; padding: 20px; border-radius: 8px; border: 1px solid #eee; margin-bottom: 30px; }
.form-title { margin-bottom: 20px; color: #EB641E; }
.form-actions { display: flex; gap: 10px; margin-top: 15px; }
.label-primary { color: var(--color-principal); }
.label-danger { color: #dc3545; }
.form-hint { font-size: 11px; color: #888; font-weight: normal; }
.checkbox-group-grid { display: flex; gap: 15px; flex-wrap: wrap; margin-top: 5px; }

/* Campos de Ofertas */
.form-group-oferta { flex-direction: row; align-items: center; gap: 10px; background: #fff4f4; padding: 10px; border-radius: 6px; border: 1px dashed #dc3545; }
.check-oferta { width: 18px; height: 18px; cursor: pointer; }
.label-oferta { margin: 0; color: #dc3545; font-size: 15px; cursor: pointer; }

/* Modales Admin */
.modal-header-title { margin-bottom: 20px; padding-bottom: 10px; border-bottom: 2px solid #eee; color: #1a1a1a; }
.modal-actions-footer { margin-top: 25px; border-top: 2px solid #eee; padding-top: 20px; display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
/* ============================================================================
   CORRECCIÓN DE Z-INDEX PARA SWEETALERT2
   ============================================================================ */
.swal2-container {
    z-index: 9999 !important;
}

/* ============================================================================
   CORRECCIÓN DE ESPACIOS EN EL PANEL DERECHO DEL POS
   ============================================================================ */

/* 1. Permite hacer scroll a todo el panel derecho si la pantalla es muy pequeña */
.pos-right {
    overflow-y: auto !important;
}

/* 2. Forzamos a que la tabla SIEMPRE tenga al menos 200px de alto, pase lo que pase */
.cart-table-container {
    flex: 1 1 200px !important;
    min-height: 200px !important;
    border-top: 1px solid #ddd;
    border-bottom: 1px solid #ddd;
}

/* 3. Hacemos la zona de pagos un poco más compacta para que no robe tanta pantalla */
.box-panel {
    padding: 10px 15px !important;
}

.pos-select-pago {
    padding: 8px !important;
    margin-bottom: 10px !important;
}

/* Reducimos el tamaño de la letra del total un poquito */
.pos-total-section p:last-child {
    font-size: 32px !important;
}

.pos-pago-row {
    margin-bottom: 5px !important;
}

/* Botón un poco más delgado pero igual de visible */
.btn-cobrar {
    padding: 15px !important;
    font-size: 20px !important;
}

/* =========================================
   ESTILOS PARA MENÚ HAMBURGUESA (MÓVIL)
========================================= */

/* Ocultar barra superior y botón "X" en pantallas grandes (PC) */
.mobile-header { display: none; }
.close-sidebar-btn { display: none; }

/* Configuración para Celulares y Tablets */
@media (max-width: 768px) {
    /* 1. Barra superior fija */
    .mobile-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        background-color: #212529; /* Mismo color de tu panel oscuro */
        padding: 15px 20px;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        z-index: 1000;
        box-shadow: 0 2px 10px rgba(0,0,0,0.3);
    }

    .mobile-title {
        color: #EB641E; /* Tu naranja oficial */
        font-weight: bold;
        font-size: 18px;
    }

    .hamburger-btn {
        background: none;
        border: none;
        color: white;
        font-size: 26px;
        cursor: pointer;
        padding: 0;
    }

    /* 2. Ocultar el menú lateral y prepararlo para deslizarse */
    .sidebar {
        position: fixed;
        top: 0;
        left: -300px; /* Escondido fuera de la pantalla hacia la izquierda */
        width: 250px;
        height: 100vh;
        z-index: 1001; /* Por encima de la barra móvil */
        transition: left 0.3s ease-in-out; /* Animación suave */
        overflow-y: auto; /* Permite hacer scroll si el menú es muy largo */
    }

    /* 3. Clase que JS aplicará para mostrar el menú */
    .sidebar.active {
        left: 0; /* Aparece en pantalla */
    }

    /* 4. Botón "X" dentro del menú */
    .close-sidebar-btn {
        display: block;
        background: none;
        border: none;
        color: white;
        font-size: 20px;
        position: absolute;
        top: 15px;
        right: 15px;
        cursor: pointer;
    }

    /* 5. Empujar el contenido principal hacia abajo para que no lo tape la barra superior */
    .main-content {
        margin-left: 0 !important; /* Elimina el margen lateral de PC */
        width: 100% !important;
        padding-top: 80px !important; /* Espacio para la barra móvil superior */
    }
}