/* ==========================================================
   1. ESTRUCTURA BASE Y SIDEBAR INTELIGENTE (TODOS LOS MODULOS)
   ========================================================== */
body {
    background-color: #f4f6f9;
    margin: 0;
    overflow-x: hidden;
    overflow-y: auto !important; 
}

@media (min-width: 768px) {
    body { display: flex; height: 100vh; overflow: hidden; }
}

#sidebar {
    min-width: 250px;
    max-width: 250px;
    background: #212529;
    color: white;
    height: 100vh;
    position: fixed;
    left: -240px; 
    top: 0;
    z-index: 2500;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 5px 0 15px rgba(0,0,0,0.3);
}

#sidebar:hover { left: 0 !important; }

#content {
    width: 100% !important;
    margin-left: 0 !important;
    overflow-y: auto;
    padding: 15px;
    transition: all 0.3s ease;
}

/* ==========================================================
   2. TSPRO - ESTILO TÁCTIL (INICIO) - PROTEGIDO
   ========================================================== */
.card-tactil {
    height: 180px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-decoration: none !important;
    border: none !important;
    border-radius: 25px !important;
    color: white !important;
    transition: transform 0.2s, box-shadow 0.2s;
    text-align: center;
}
.card-tactil:hover { transform: translateY(-5px); box-shadow: 0 10px 20px rgba(0,0,0,0.2) !important; }
.card-tactil:active { transform: scale(0.95); }
.card-tactil i { font-size: 4rem; margin-bottom: 10px; }
.card-tactil span { font-size: 1.2rem; font-weight: bold; text-transform: uppercase; letter-spacing: 1px; }

/* GRADIENTES TSPRO */
.bg-grad-success { background: linear-gradient(135deg, #28a745, #1e7e34); }
.bg-grad-primary { background: linear-gradient(135deg, #0d6efd, #0b5ed7); }
.bg-grad-info    { background: linear-gradient(135deg, #17a2b8, #117a8b); }
.bg-grad-cyan    { background: linear-gradient(135deg, #0dcaf0, #0aa2c0); }
.bg-grad-warning { background: linear-gradient(135deg, #ffc107, #d39e00); }
.bg-grad-purple  { background: linear-gradient(135deg, #6f42c1, #522791); }
.bg-grad-dark    { background: linear-gradient(135deg, #343a40, #1d2124); }
.bg-grad-rose    { background: linear-gradient(135deg, #f43f5e, #be123c); }
.bg-grad-teal    { background: linear-gradient(135deg, #14b8a6, #0d9488); }
.bg-grad-indigo  { background: linear-gradient(135deg, #6366f1, #4338ca); }
.bg-grad-success-dark { background: linear-gradient(135deg, #15803d, #166534); }

/* ==========================================================
   3. DISEÑO POS "FULL WIDTH" COMPACTADO (MÁS ESPACIO PARA PRODUCTOS)
   ========================================================== */
.pos-master { 
    display: flex; 
    flex-direction: column; 
    height: calc(100vh - 75px); 
    background-color: #f4f6f9; 
    padding: 5px 10px; 
    gap: 10px; 
    font-family: 'Segoe UI', sans-serif;
}

/* 3.1. BARRA SUPERIOR (MÁS DELGADA) */
.pos-top-bar { 
    background: #ffffff; border-radius: 10px; padding: 10px 15px; box-shadow: 0 2px 5px rgba(0,0,0,0.05); 
    display: flex; gap: 15px; align-items: center; z-index: 100; flex-shrink: 0;
}
.search-container { flex: 1; position: relative; }
.pos-search-input { 
    width: 100%; font-size: 1.1rem; padding: 8px 15px 8px 45px; 
    border: 2px solid #0d6efd; border-radius: 8px; background: #f8fafc; font-weight: bold; color: #1e293b;
}
.pos-search-input:focus { outline: none; box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.15); background: white; }
.search-icon { position: absolute; left: 15px; top: 50%; transform: translateY(-50%); font-size: 1.2rem; color: #0d6efd; }

.floating-results { 
    position: absolute; top: 100%; left: 0; right: 0; background: white; border-radius: 8px; 
    box-shadow: 0 10px 25px rgba(0,0,0,0.15); max-height: 300px; overflow-y: auto; display: none; margin-top: 5px; border: 1px solid #e2e8f0;
}
.result-item { padding: 10px 15px; border-bottom: 1px solid #f1f5f9; cursor: pointer; display: flex; justify-content: space-between; align-items: center; }
.result-item:hover, .result-item.active { background: #eff6ff; border-left: 4px solid #0d6efd; }

.client-selector { width: 300px; max-width: 100%; font-size: 1rem; border: 2px solid #e2e8f0; border-radius: 8px; padding: 8px; background: white; font-weight: bold;}
.client-selector:focus { border-color: #0d6efd; outline: none;}
.factura-badge { background: #1e293b; color: white; padding: 8px 15px; border-radius: 8px; font-weight: 900; font-size: 1rem;}

/* 3.2. ZONA CENTRAL (MÁXIMO ESPACIO PARA TABLA) */
.pos-table-area { 
    flex: 1; background: white; border-radius: 10px; box-shadow: 0 2px 5px rgba(0,0,0,0.05); overflow-y: auto; border: 1px solid #e2e8f0;
}
.table-pos { width: 100%; margin: 0; border-collapse: separate; border-spacing: 0; }
.table-pos thead th { 
    position: sticky; top: 0; background: #0d6efd; color: white; padding: 10px; 
    font-size: 0.85rem; text-transform: uppercase; font-weight: bold; border-bottom: 3px solid #0a58ca; z-index: 10;
}
.table-pos tbody td { padding: 6px 10px; vertical-align: middle; border-bottom: 1px solid #f1f5f9; font-size: 0.95rem; }
.table-pos tbody tr:hover { background-color: #f8fafc; }

/* Controles dentro de la tabla (más pequeños) */
.tbl-select { border: 1px solid #cbd5e1; border-radius: 5px; padding: 4px; font-weight: bold; color: #0d6efd; background: #f8fafc; cursor: pointer; outline: none; width: 100%; font-size: 0.9rem;}
.tbl-input { border: 1px solid #cbd5e1; border-radius: 5px; padding: 4px; font-weight: bold; text-align: center; width: 70px; outline: none; font-size: 1rem;}
.tbl-select:focus, .tbl-input:focus { border-color: #0d6efd; background: white;}

/* 3.3. BARRA INFERIOR (COMPACTADA) */
.pos-bottom-bar { 
    background: white; border-radius: 10px; padding: 10px 15px; box-shadow: 0 -3px 10px rgba(0,0,0,0.03); 
    display: grid; grid-template-columns: 1fr 1fr 1.5fr; gap: 15px; align-items: center; border: 1px solid #e2e8f0; flex-shrink: 0;
}

.panel-box { background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 8px; padding: 10px; height: 100%; display: flex; flex-direction: column; justify-content: center;}
.panel-title { font-size: 0.7rem; font-weight: bold; color: #64748b; margin-bottom: 5px; text-transform: uppercase; letter-spacing: 0.5px;}

.payment-pills-container { display: flex; gap: 6px; margin-bottom: 6px; }
.payment-pill { flex: 1; border: 1px solid #cbd5e1; border-radius: 6px; padding: 6px 0; text-align: center; cursor: pointer; font-weight: bold; color: #64748b; transition: 0.2s; background: white; font-size: 0.75rem;}
.payment-pill.active { background: #eff6ff; border-color: #0d6efd; border-width: 2px; color: #0d6efd; }

.input-money { font-size: 1.2rem; font-weight: 900; color: #198754; border: 2px solid #e2e8f0; border-radius: 6px; padding: 4px 10px; width: 100%; outline: none;}
.input-money:focus { border-color: #198754; background: #f6fcf9;}

.text-cambio { font-size: 1.5rem; font-weight: 900; color: #0d6efd; margin: 0; line-height: 1;}
.text-total-gigante { font-size: 2.5rem; font-weight: 900; color: #0d6efd; text-align: right; line-height: 1; margin: 0;}

.btn-checkout-mega { 
    background: #198754; color: white; border: none; width: 100%; border-radius: 8px; 
    font-size: 1.2rem; font-weight: 900; padding: 10px; margin-top: 5px; transition: 0.2s; box-shadow: 0 4px 10px rgba(25, 135, 84, 0.2); text-transform: uppercase;
}
.btn-checkout-mega:hover { background: #157347; transform: translateY(-1px); }

/* Scrollbars */
.pos-table-area::-webkit-scrollbar, .floating-results::-webkit-scrollbar { width: 6px; }
.pos-table-area::-webkit-scrollbar-thumb, .floating-results::-webkit-scrollbar-thumb { background-color: #cbd5e1; border-radius: 10px; }

/* ==========================================================
   4. ADAPTABILIDAD MÓVIL (MEDIA QUERIES)
   ========================================================== */
@media (max-width: 768px) {
    /* Permitir que el POS haga scroll en teléfonos en lugar de cortarse */
    .pos-master {
        height: auto;
        min-height: 100vh;
    }

    /* Apilar la barra superior (Buscador y Cliente) */
    .pos-top-bar {
        flex-direction: column;
        align-items: stretch;
    }
    .client-selector {
        width: 100%;
    }

    /* Apilar los paneles de la barra inferior (Cobro y Total) */
    .pos-bottom-bar {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    
    .text-total-gigante {
        text-align: center;
        font-size: 2rem;
    }
}