@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap');

/* ===============================
   VARIABLES
================================ */

:root {
    --bg: #f3f4f6;
    --card: #ffffff;
    --text: #1f2937;
    --muted: #6b7280;
    --border: #e5e7eb;
    --primary: #3b82f6;
    --success: #10b981;
    --shadow: 0 6px 20px rgba(0,0,0,0.06);
}

/* Modo oscuro */
:root.dark {
    --bg: #111827;
    --card: #1f2937;
    --text: #f9fafb;
    --muted: #9ca3af;
    --border: #374151;
    --primary: #60a5fa;
    --success: #34d399;
    --shadow: 0 6px 20px rgba(0,0,0,0.4);
}

body {
    font-family: 'Inter', sans-serif;
    background: var(--bg);
    color: var(--text);
    margin: 0;
    transition: background 0.3s ease, color 0.3s ease;
}

/* ===============================
   LAYOUT PANTALLA COMPLETA
================================ */

#tpv {
   max-width: 1100px;
    margin: auto;
    padding: 20px;
}

/* Tablet optimizado */
@media (max-width: 1024px) {
    #tpv {
        padding: 15px;
    }
}

/* ===============================
   BUSCADOR PRODUCTOS
================================ */

#search {
    width: 100%;
    padding: 18px;
    font-size: 20px;
    border-radius: 14px;
    border: 1px solid var(--border);
    background: var(--card);
    box-shadow: var(--shadow);
    transition: all 0.2s ease;
}

#search:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59,130,246,0.2);
}

/* ===============================
   SUGERENCIAS MÁS LIMPIAS
================================ */

.suggestion {
    background: var(--card);
    padding: 14px 16px;
    margin-bottom: 8px;
    border-radius: 14px;
    box-shadow: var(--shadow);
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.15s ease;
    cursor: pointer;
}

.suggestion:hover {
    transform: translateY(-2px);
}

.suggestion strong {
    font-size: 15px;
}

.suggestion small {
    color: var(--muted);
}

/* ===============================
   CARRITO
================================ */

table {
    width: 100%;
    background: var(--card);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: var(--shadow);
}

td, th {
    padding: 14px;
    border-bottom: 1px solid var(--border);
}

tr:last-child td {
    border-bottom: none;
}

/* ===============================
   ANIMACIÓN AL AÑADIR PRODUCTO
================================ */

@keyframes popIn {
    0% { transform: scale(0.95); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

table tr {
    animation: popIn 0.2s ease;
}

/* ===============================
   BOTONES TÁCTILES
================================ */

button {
    padding: 10px 14px;
    font-size: 16px;
    border-radius: 10px;
    border: none;
    cursor: pointer;
    transition: all 0.15s ease;
}

button:active {
    transform: scale(0.96);
}

/* ===============================
   BARRA DE PAGO
================================ */

#payment-bar {
    display: flex;
    gap: 18px;
    margin-top: 25px;
}

.pay-btn {
    flex: 1;
    padding: 24px;
    font-size: 22px;
    font-weight: 600;
    border-radius: 18px;
}

.pay-btn.cash {
    background: var(--success);
    color: white;
}

.pay-btn.card {
    background: var(--primary);
    color: white;
}

.pay-btn:hover {
    transform: translateY(-2px);
}

/* ===============================
   CLIENTE MODERNO
================================ */

.customer-selector {
    margin-bottom: 12px;
    position: relative;
}

#customerSearch {
    width: 280px;
    padding: 10px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--card);
}

#customerResults {
    position: absolute;
    top: 48px;
    left: 0;
    width: 280px;
    background: var(--card);
    border-radius: 14px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    max-height: 240px;
    overflow-y: auto;

    opacity: 0;
    transform: translateY(-6px);
    transition: opacity 0.15s ease, transform 0.15s ease;
    pointer-events: none;
}

#customerResults:not(:empty) {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

#selectedCustomer {
    display: inline-block;
    margin-top: 6px;
    padding: 6px 12px;
    font-size: 13px;
    border-radius: 30px;
    background: var(--border);
}

#selectedCustomer::before {
    content: "👤 ";
}

/* ===============================
   TRANSICIÓN AL IMPRIMIR
================================ */

body.printing {
    opacity: 0;
    transition: opacity 0.2s ease;
}
/* ===============================
   FIX MODALES
================================ */

/* ===============================
   MODAL EFECTIVO RESTAURADO
================================ */

.cash-modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.cash-modal.hidden {
    display: none !important;
}

.cash-box {
    background: #ffffff;
    padding: 20px;
    width: 320px;
    border-radius: 8px;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0,0,0,0.25);
}

/* Título */
.cash-box h2 {
    margin-top: 0;
    font-size: 20px;
}

/* Teclado restaurado en grid real */
.cash-keypad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin: 15px 0;
}

.cash-keypad button {
    font-size: 20px;
    padding: 15px;
    border-radius: 6px;
    background: #f3f3f3;
    border: 1px solid #ddd;
}

.cash-keypad button:active {
    transform: scale(0.96);
}

/* Botones acción */
.cash-actions {
    display: flex;
    gap: 10px;
}

.cash-actions button {
    flex: 1;
    padding: 12px;
    border-radius: 6px;
}

/* Confirmar */
#cashConfirm {
    background: #2ecc71;
    color: white;
}

/* Cancelar */
#cashCancel {
    background: #e5e7eb;
}

/* ESTA LÍNEA ES LA CLAVE */
.cash-modal.hidden {
    display: none !important;
}
/* ===============================
   TOGGLE MODO OSCURO
================================ */

.theme-toggle {
    position: fixed;
    top: 15px;
    right: 20px;
    z-index: 9999;
}

#themeToggle {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--card);
    cursor: pointer;
    font-size: 16px;
    transition: all 0.2s ease;
    box-shadow: var(--shadow);
}

#themeToggle:hover {
    transform: scale(1.08);
}
/* ===============================
   MODO OSCURO MANUAL
================================ */

.dark {
    --bg: #111827;
    --card: #1f2937;
    --text: #f9fafb;
    --muted: #9ca3af;
    --border: #374151;
    --primary: #60a5fa;
    --success: #34d399;
    --shadow: 0 6px 20px rgba(0,0,0,0.4);
}
/* ===============================
   SWITCH MODO OSCURO iOS
================================ */

.theme-toggle {
    position: fixed;
    top: 18px;
    right: 20px;
    z-index: 9999;
}

/* Contenedor switch */
.switch {
    position: relative;
    display: inline-block;
    width: 46px;
    height: 26px;
}

/* Ocultamos checkbox real */
.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

/* Fondo */
.slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background-color: #e5e7eb;
    transition: 0.3s;
    border-radius: 34px;
}

/* Círculo */
.slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

/* Activo */
.switch input:checked + .slider {
    background-color: var(--primary);
}

.switch input:checked + .slider:before {
    transform: translateX(20px);
}

/* Suavizar transición global */
body {
    transition: background 0.25s ease, color 0.25s ease;
}
/* ===============================
   SWITCH iOS PREMIUM
================================ */

.theme-toggle {
    position: fixed;
    top: 18px;
    right: 20px;
    z-index: 9999;
}

.switch {
    position: relative;
    display: inline-block;
    width: 58px;
    height: 30px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

/* Fondo */
.slider {
    position: absolute;
    inset: 0;
    background-color: #e5e7eb;
    border-radius: 40px;
    transition: all 0.35s ease;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 8px;
}

/* Glow azul suave */
.switch input:checked + .slider {
    background-color: var(--primary);
    box-shadow: 0 0 12px rgba(59,130,246,0.6);
}

/* Círculo */
.slider::before {
    content: "";
    position: absolute;
    height: 24px;
    width: 24px;
    left: 3px;
    top: 3px;
    background: white;
    border-radius: 50%;
    transition: transform 0.35s ease;
    box-shadow: 0 3px 8px rgba(0,0,0,0.25);
}

.switch input:checked + .slider::before {
    transform: translateX(28px);
}

/* Iconos */
.icon {
    font-size: 13px;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.sun {
    opacity: 1;
}

.moon {
    opacity: 0.5;
}

.switch input:checked + .slider .sun {
    opacity: 0.5;
}

.switch input:checked + .slider .moon {
    opacity: 1;
}

/* ===============================
   TRANSICIÓN FADE GLOBAL
================================ */

body {
    transition: background 0.4s ease, color 0.4s ease;
}

#tpv, table, .suggestion, #search {
    transition: background 0.4s ease, color 0.4s ease, box-shadow 0.4s ease;
}
/* ===============================
   MODAL - MODO OSCURO
================================ */

:root.dark .cash-box {
    background: #1f2937;
    color: #f9fafb;
    box-shadow: 0 15px 40px rgba(0,0,0,0.6);
}

:root.dark .cash-box h2 {
    color: #f9fafb;
}

:root.dark .cash-keypad button {
    background: #374151;
    border: 1px solid #4b5563;
    color: #f9fafb;
}

:root.dark .cash-keypad button:hover {
    background: #4b5563;
}

:root.dark #cashConfirm {
    background: #10b981;
    color: white;
}

:root.dark #cashCancel {
    background: #374151;
    color: #f9fafb;
}
/* ===============================
   FIX MODAL DEVOLUCIONES
================================ */

/* Modal más ancho si es devolución */
#refundModal .cash-box {
    width: 480px;
    max-width: 95vw;
}

/* Forzar ajuste de texto */
#refundModal td {
    word-wrap: break-word;
    font-size: 14px;
}

/* Scroll suave táctil */
#refundLines {
    -webkit-overflow-scrolling: touch;
}
#loginScreen {
    position: fixed;
    top:0;
    left:0;
    width:100%;
    height:100%;
    background:#f5f5f5;
    z-index:9999;
    display:flex;
    align-items:center;
    justify-content:center;
}

#loginScreen .modal-content{
    background:#fff;
    padding:30px;
    border-radius:6px;
    width:350px;
}
#navbar {
    display: flex;
    background: #111;
    color: #fff;
}

.nav-item {
    padding: 15px 20px;
    cursor: pointer;
}

.nav-item.active {
    background: #333;
}

.screen {
    display: none;
    padding: 20px;
}

.screen.active {
    display: block;
}

.screen-header {
    border-bottom: 1px solid #ccc;
    margin-bottom: 20px;
}
.report-card {
    background: #fff;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}
#loginScreen {
    position: fixed;
    inset: 0;
    z-index: 9999; /* 🔥 clave */
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
}