/* ====== RESET Y BASE ====== */
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; background-color: #f0f2f5; color: #333; }
a { text-decoration: none; color: inherit; }

/* ====== NAVBAR (Para todas las pantallas logueadas) ====== */
.navbar { background: #1e293b; color: white; padding: 15px 30px; display: flex; justify-content: space-between; align-items: center; gap: 12px 22px; flex-wrap: wrap; box-shadow: 0 2px 5px rgba(0,0,0,0.2); }
.navbar h2 { font-size: 22px; min-width: 0; overflow-wrap: anywhere; }
.nav-links { display: flex; gap: 15px; }
.nav-links a { background: #334155; padding: 10px 20px; border-radius: 6px; font-weight: bold; font-size: 16px; transition: 0.2s; }
.nav-links a:hover { background: #475569; }
.nav-links a.active { background: #3b82f6; color: white; }

/* ====== LOGIN ====== */
.login-body { display: flex; justify-content: center; align-items: center; height: 100vh; background: #1e293b; }
.login-box { background: white; padding: 40px; border-radius: 12px; width: 400px; box-shadow: 0 10px 25px rgba(0,0,0,0.3); }
.login-box h2 { text-align: center; margin-bottom: 20px; color: #1e293b; }
.login-box select, .login-box input { width: 100%; padding: 12px; margin: 10px 0; border: 1px solid #ccc; border-radius: 6px; font-size: 16px; }
.login-box button { width: 100%; padding: 15px; background: #3b82f6; color: white; border: none; border-radius: 6px; font-size: 18px; font-weight: bold; cursor: pointer; margin-top: 10px; }
.login-box button:hover { background: #2563eb; }

/* ====== PANTALLA DE VENTAS (CAJA) ====== */
.container-ventas { display: flex; height: calc(100vh - 70px); }
.panel-productos { flex: 2; padding: 20px; overflow-y: auto; background: #fff; }
.grid-productos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.btn-producto { background: #3b82f6; color: white; border: none; border-radius: 10px; padding: 30px; font-size: 18px; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 150px; box-shadow: 0 4px 6px rgba(0,0,0,0.1); transition: 0.2s; }
.btn-producto:hover { background: #2563eb; transform: translateY(-2px); }
.btn-producto span { background: rgba(0,0,0,0.2); padding: 5px 10px; border-radius: 4px; margin-top: 10px; font-size: 16px; }

.panel-carrito { flex: 1; background: #1e293b; color: white; padding: 20px; display: flex; flex-direction: column; }
.lista-carrito { flex: 1; overflow-y: auto; margin-bottom: 20px; }
.item-carrito { background: #334155; padding: 15px; margin-bottom: 10px; border-radius: 8px; display: flex; justify-content: space-between; align-items: center; border-left: 5px solid #3b82f6; }
.total-container { border-top: 2px solid #475569; padding-top: 20px; text-align: right; }
.total-text { font-size: 18px; color: #94a3b8; }
.total-amount { font-size: 36px; font-weight: bold; color: #4ade80; margin-bottom: 20px; }
select { width: 100%; padding: 15px; font-size: 18px; margin-bottom: 20px; border-radius: 8px; background: #0f172a; color: white; border: 1px solid #475569; }
.btn-pagar { background: #4ade80; color: #0f172a; padding: 20px; font-size: 20px; border: none; border-radius: 8px; width: 100%; font-weight: bold; cursor: pointer; }
.btn-vaciar { background: transparent; color: #f87171; border: 2px solid #f87171; padding: 12px; width: 100%; border-radius: 8px; font-weight: bold; cursor: pointer; margin-top: 10px; }

/* ====== TARJETAS (GARZON, COCINERO, ADMIN) ====== */
.grid-cards { padding: 30px; display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 25px; }
.card { background: white; border-radius: 12px; box-shadow: 0 4px 6px rgba(0,0,0,0.1); overflow: hidden; display: flex; flex-direction: column; border-top: 6px solid #3b82f6; }
.card.warning { border-top-color: #f59e0b; }
.card.danger { border-top-color: #ef4444; }
.card.success { border-top-color: #10b981; }
.card-header { padding: 20px; background: #f8fafc; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid #e2e8f0; }
.card-title { font-size: 22px; font-weight: bold; color: #1e293b; }
.card-timer { font-size: 20px; font-weight: bold; color: #ef4444; background: #fee2e2; padding: 5px 10px; border-radius: 6px; }
.card-body { padding: 20px; flex: 1; }
.pedido-item { background: #f1f5f9; padding: 10px; margin-bottom: 8px; border-radius: 6px; font-weight: 500; }
.btn-card { width: 100%; padding: 15px; border: none; font-size: 18px; font-weight: bold; cursor: pointer; margin-top: auto; }
.btn-liberar { background: #10b981; color: white; }
.btn-liberar:hover { background: #059669; }
.btn-listo { background: #3b82f6; color: white; }
.btn-listo:hover { background: #2563eb; }

/* ====== ESTADÍSTICAS (ADMIN Y CAJERO) ====== */
.stats-container { display: flex; justify-content: center; gap: 30px; padding: 50px; flex-wrap: wrap; }
.stat-card { background: white; padding: 30px; border-radius: 12px; width: 300px; text-align: center; box-shadow: 0 4px 6px rgba(0,0,0,0.1); border-bottom: 6px solid #3b82f6; }
.stat-card h3 { color: #64748b; font-size: 18px; margin-bottom: 15px; text-transform: uppercase; }
.stat-card .number { font-size: 48px; font-weight: bold; color: #1e293b; }
.empty-state { text-align: center; padding: 50px; color: #64748b; font-size: 20px; }


/* ===== MENSAJES ===== */
.messages { padding: 15px; background: #fef3c7; }
.alert { background: #3b82f6; color: white; padding: 10px; margin: 5px 0; border-radius: 6px; }
.alert.alert-error, .alert.alert-danger { background: #ef4444; }
.alert.alert-success { background: #10b981; }

/* ===== BOTONES DE ACCIÓN EN ITEMS ===== */
.item-actions { display: flex; gap: 5px; align-items: center; }
.btn-cant { background: #475569; color: white; padding: 5px 10px; border-radius: 4px; font-size: 14px; }
.btn-cant.btn-delete { background: #ef4444; }

/* ===== INFO / NOTAS ===== */
.demo-info { margin-top: 20px; padding: 15px; background: #f1f5f9; border-radius: 8px; font-size: 13px; }
.demo-info h4 { margin-bottom: 8px; color: #1e293b; }
.login-note { margin-top: 18px; text-align: center; color: #64748b; font-size: 12px; line-height: 1.5; }

/* ===== FORMULARIOS EN LÍNEA (ACCIONES POST) ===== */
.form-inline { display: inline; margin: 0; padding: 0; }
.form-producto { display: contents; }
.btn-cant { border: none; cursor: pointer; font-family: inherit; }
button.btn-cant { line-height: 1; }

/* ===== LOGOUT ===== */
.btn-logout { background: #ef4444 !important; }
.btn-logout:hover { background: #dc2626 !important; }
.nav-btn { background: #ef4444; color: white; padding: 10px 20px; border: none; border-radius: 6px; font-weight: bold; font-size: 16px; cursor: pointer; font-family: inherit; }
.nav-btn:hover { background: #dc2626; }

/* ====== MODALES ====== */
.modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.6); display: none; justify-content: center; align-items: center; z-index: 1000; }
.modal-box { background: white; padding: 30px; border-radius: 12px; width: 400px; text-align: center; box-shadow: 0 10px 25px rgba(0,0,0,0.3); }
.modal-box h3 { margin-bottom: 15px; color: #1e293b; }
.modal-box p { margin-bottom: 25px; color: #64748b; }
.modal-actions { display: flex; justify-content: center; gap: 15px; align-items: center; }
.modal-actions button { max-width: none !important; width: auto !important; padding: 10px 20px !important; }
.modal-actions form { flex: 1; }
.modal-actions form button { width: 100% !important; padding: 10px !important; }

/* ====== ZONA DE PELIGRO ====== */
.danger-zone { border: 2px solid #ef4444; border-radius: 12px; padding: 20px; margin: 40px auto; max-width: 800px; text-align: center; background: #fff0f0; }
.danger-zone h3 { color: #ef4444; margin-bottom: 10px; }
.danger-zone p { color: #991b1b; margin-bottom: 20px; font-size: 14px; }

/* ====== BOTÓN NUEVO DÍA ====== */
.btn-nuevo-dia { background: #10b981; color: white; padding: 15px 40px; border: none; border-radius: 8px; font-size: 18px; font-weight: bold; cursor: pointer; box-shadow: 0 4px 6px rgba(0,0,0,0.1); transition: 0.2s; }
.btn-nuevo-dia:hover { background: #059669; transform: translateY(-2px); }

/* ====== FONDOS Y COLORES POR ROL ====== */

/* Clases base para los fondos */
body.bg-login, body.bg-garzon, body.bg-cocinero, body.bg-cajero, body.bg-admin {
    background-size: cover;
    background-position: center center;
    background-attachment: fixed; /* Efecto parallax sutil */
    position: relative;
}

/* ====== FONDOS Y COLORES POR ROL ====== */

/* Clases base para los fondos */
body.bg-login, body.bg-garzon, body.bg-cocinero, body.bg-cajero, body.bg-admin {
    background-size: cover;
    background-position: center center;
    background-attachment: fixed; /* Efecto parallax sutil */
    position: relative;
}

/* Fondo Login */
body.bg-login {
    background-image: linear-gradient(rgba(15, 23, 42, 0.8), rgba(15, 23, 42, 0.8)), url('/static/img/fondo-login.jpg');
}

/* Fondos de trabajo */
body.bg-garzon {
    background-image: linear-gradient(rgba(255, 255, 255, 0.92), rgba(255, 255, 255, 0.92)), url('/static/img/fondo-garzon.jpg');
}
body.bg-cocinero {
    background-image: linear-gradient(rgba(255, 255, 255, 0.92), rgba(255, 255, 255, 0.92)), url('/static/img/fondo-cocinero.jpg');
}
body.bg-cajero {
    background-image: linear-gradient(rgba(255, 255, 255, 0.92), rgba(255, 255, 255, 0.92)), url('/static/img/fondo-cajero.jpg');
}
body.bg-admin {
    background-image: linear-gradient(rgba(255, 255, 255, 0.92), rgba(255, 255, 255, 0.92)), url('/static/img/fondo-admin.jpg');
}

/* Colores de Navbar por Rol */
.navbar.navbar-garzon { background: #10b981; } 
.navbar.navbar-cocinero { background: #f59e0b; } 
.navbar.navbar-cajero { background: #3b82f6; } 
.navbar.navbar-admin { background: #4f46e5; } 

.navbar.navbar-garzon h2, .navbar.navbar-garzon a, 
.navbar.navbar-cocinero h2, .navbar.navbar-cocinero a,
.navbar.navbar-cajero h2, .navbar.navbar-cajero a,
.navbar.navbar-admin h2, .navbar.navbar-admin a {
    color: white;
}

/* Resaltado de la sección actual: debe contrastar con el color del rol. */
.navbar.navbar-cajero .nav-links a.active,
.navbar.navbar-garzon .nav-links a.active,
.navbar.navbar-admin .nav-links a.active {
    background: #ffffff;
    color: #1e293b;
    box-shadow: inset 0 0 0 2px rgba(15, 23, 42, .18);
}

.navbar.navbar-cocinero .nav-links a.active {
    background: #1e293b;
    color: #ffffff;
    box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .35);
}

/* ====== UTILIDADES COMPARTIDAS ====== */
.nav-links { flex-wrap: wrap; align-items: center; flex: 1 1 auto; justify-content: flex-end; row-gap: 8px; }
.nav-links a, .nav-links .nav-btn { white-space: nowrap; max-width: 100%; }
.nav-links .form-inline { display: flex; align-items: center; }
.container-admin { padding: 30px; max-width: 1150px; margin: 0 auto; }
.panel { background: #fff; border-radius: 12px; padding: 22px; box-shadow: 0 2px 6px rgba(0,0,0,.08); margin-bottom: 22px; }
.panel h3 { color: #1e293b; border-bottom: 2px solid #3b82f6; padding-bottom: 10px; margin-bottom: 16px; }
.panel h4 { color: #334155; margin-bottom: 12px; }
.grid-modulos { display: grid; grid-template-columns: repeat(auto-fill, minmax(175px, 1fr)); gap: 14px; }
.modulo-card { display: flex; flex-direction: column; gap: 6px; background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 10px; padding: 16px; font-weight: 700; color: #1e293b; transition: .2s; }
.modulo-card:hover { background: #eff6ff; border-color: #3b82f6; transform: translateY(-2px); }
.modulo-card small { color: #64748b; font-weight: 400; }
.table-responsive { overflow-x: auto; }
.tabla { width: 100%; border-collapse: collapse; background: #fff; border-radius: 12px; overflow: hidden; box-shadow: 0 2px 4px rgba(0,0,0,.06); }
.tabla th { background: #1e293b; color: #fff; padding: 12px; text-align: left; font-size: 14px; }
.tabla td { padding: 10px 12px; border-bottom: 1px solid #e2e8f0; font-size: 14px; vertical-align: top; }
.tabla tr:hover td { background: #f8fafc; }
.badge { display: inline-block; padding: 4px 10px; border-radius: 20px; font-size: 12px; font-weight: 700; }
.badge-ok { background: #d1fae5; color: #065f46; }
.badge-off { background: #fee2e2; color: #991b1b; }
.badge-info { background: #dbeafe; color: #1e40af; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.form-grid .campo-full { grid-column: 1 / -1; }
.form-grid label { display: block; font-weight: 600; color: #334155; margin-bottom: 5px; font-size: 14px; }
.form-grid input, .form-grid select, .form-grid textarea { width: 100%; padding: 11px; border: 1px solid #cbd5e1; border-radius: 8px; font-size: 15px; background: #fff; color: #0f172a; }
.form-grid input[type="checkbox"] { width: auto; }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
.btn { display: inline-block; padding: 11px 18px; border-radius: 8px; border: none; cursor: pointer; font-weight: 700; font-size: 15px; font-family: inherit; text-align: center; }
.btn-primary { background: #3b82f6; color: #fff; }
.btn-primary:hover { background: #2563eb; }
.btn-success { background: #10b981; color: #fff; }
.btn-success:hover { background: #059669; }
.btn-danger { background: #ef4444; color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-secondary { background: #e2e8f0; color: #1e293b; }
.btn-secondary:hover { background: #cbd5e1; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.inline-form { display: inline; margin: 0; padding: 0; }
.muted { color: #64748b; }
.text-right { text-align: right; }
.stat-inline { display: flex; gap: 18px; flex-wrap: wrap; }
.stat-inline > div { background: #f8fafc; border-radius: 8px; padding: 12px 18px; min-width: 150px; }
.stat-inline strong { display: block; font-size: 22px; color: #1e293b; }
.cuadratura-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.input-cuadratura { width: 100%; padding: 9px; border: 1px solid #cbd5e1; border-radius: 6px; font-size: 15px; }
.campo-observacion label { display: block; font-weight: 600; color: #334155; margin-bottom: 5px; font-size: 14px; }
.campo-observacion textarea { width: 100%; min-height: 78px; padding: 11px; border: 1px solid #cbd5e1; border-radius: 8px; font-family: inherit; font-size: 15px; resize: vertical; }
.totales-cuadratura { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 16px; font-weight: 700; background: #f1f5f9; padding: 14px; border-radius: 8px; }
.mensaje-vacio { text-align: center; color: #64748b; padding: 18px; }
.paginacion { display: flex; gap: 10px; justify-content: center; margin-top: 16px; }
@media (max-width: 700px) {
    .navbar { flex-direction: column; gap: 12px; align-items: flex-start; padding: 15px 18px; }
    .nav-links { width: 100%; justify-content: flex-start; }
    .container-ventas { flex-direction: column; height: auto; }
    .grid-productos { grid-template-columns: repeat(2, 1fr); }
    .stats-container { padding: 20px; }
}
/* ====== SELECTOR BUSCABLE ====== */
.select-buscable { position: relative; width: 100%; }
.select-buscable-original { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: 0 !important; border: 0 !important; opacity: 0 !important; pointer-events: none; }
.select-buscable-campo { width: 100%; box-sizing: border-box; }
.select-buscable-lista { position: absolute; left: 0; right: 0; top: calc(100% + 4px); max-height: 240px; overflow-y: auto; background: #fff; border: 1px solid #cbd5e1; border-radius: 8px; box-shadow: 0 12px 28px rgba(15, 23, 42, .16); z-index: 80; }
.select-buscable-opcion { display: block; width: 100%; padding: 10px 12px; border: 0; background: #fff; color: #0f172a; text-align: left; cursor: pointer; font: inherit; }
.select-buscable-opcion:hover, .select-buscable-opcion.activo, .select-buscable-opcion.seleccionada { background: #eff6ff; }
.select-buscable-vacio { padding: 10px 12px; color: #64748b; }
.panel-carrito .select-buscable { margin-bottom: 20px; }
.panel-carrito .select-buscable-campo { padding: 15px; font-size: 18px; border-radius: 8px; background: #0f172a; color: white; border: 1px solid #475569; }
.panel-carrito .select-buscable-lista { background: #0f172a; border-color: #475569; }
.panel-carrito .select-buscable-opcion { background: #0f172a; color: white; }
.panel-carrito .select-buscable-opcion:hover, .panel-carrito .select-buscable-opcion.activo, .panel-carrito .select-buscable-opcion.seleccionada { background: #334155; }

/* ====== STOCK EN COCINA ====== */
.stock-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.stock-item { display: grid; grid-template-columns: 1fr 88px auto; align-items: center; gap: 8px; background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 8px; padding: 8px 10px; margin: 0; }
.stock-nombre { font-weight: 600; color: #1e293b; font-size: 14px; }
.stock-item input[type="number"] { width: 100%; padding: 8px; border: 1px solid #cbd5e1; border-radius: 6px; font-size: 14px; }
.stock-item .btn { padding: 8px 10px; font-size: 12px; }

/* ====== COCINA: PANTALLA TÁCTIL ======
   Todo este bloque está limitado a body.bg-cocinero para no alterar las
   pantallas de garzón, cajero ni admin. El cocinero trabaja de pie, con las
   manos ocupadas y con pantalla táctil: cada control tiene ~56px de alto
   mínimo y texto grande, para acertar sin apuntar con precisión. */

body.bg-cocinero button,
body.bg-cocinero .nav-links a {
    touch-action: manipulation;            /* quita el retardo por doble toque */
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

/* --- Barra de navegación --- */
body.bg-cocinero .navbar { padding: 18px 28px; }
body.bg-cocinero .navbar h2 { font-size: 30px; }
body.bg-cocinero .nav-links { gap: 12px; }
body.bg-cocinero .nav-links a,
body.bg-cocinero .nav-links .nav-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 58px;
    padding: 14px 28px;
    font-size: 20px;
    border-radius: 10px;
}

/* --- Tarjetas de órdenes pendientes --- */
body.bg-cocinero .grid-cards {
    padding: 28px;
    grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
    gap: 28px;
}
body.bg-cocinero .card { border-radius: 14px; }
body.bg-cocinero .card-header { padding: 22px 24px; flex-wrap: wrap; gap: 10px; }
body.bg-cocinero .card-title { font-size: 26px; }
body.bg-cocinero .card-timer {
    font-size: 26px;
    padding: 8px 14px;
    border-radius: 8px;
    font-variant-numeric: tabular-nums;
}
body.bg-cocinero .card-body { padding: 22px 24px; font-size: 19px; }
body.bg-cocinero .pedido-item {
    font-size: 20px;
    padding: 15px 16px;
    margin-bottom: 10px;
    border-radius: 8px;
}
body.bg-cocinero .btn-card {
    padding: 28px 20px;
    min-height: 88px;
    font-size: 27px;
    letter-spacing: .5px;
    box-shadow: inset 0 -4px 0 rgba(0, 0, 0, .18);
}
body.bg-cocinero .btn-card:active {
    transform: translateY(2px);
    box-shadow: inset 0 0 0 rgba(0, 0, 0, .18);
}
body.bg-cocinero .btn-listo { background: #2563eb; }
body.bg-cocinero .empty-state { font-size: 26px; padding: 60px 30px; }
body.bg-cocinero .empty-state small { font-size: 18px; }

/* --- Paneles de disponibilidad y stock --- */
body.bg-cocinero .panel { padding: 26px; }
body.bg-cocinero .panel h3 { font-size: 26px; padding-bottom: 12px; }
body.bg-cocinero .panel .muted { font-size: 17px; line-height: 1.5; }
body.bg-cocinero .stock-grid {
    grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
    gap: 14px;
}
body.bg-cocinero .stock-item {
    grid-template-columns: 1fr auto;
    gap: 12px 14px;
    padding: 14px 16px;
    border-radius: 10px;
}
body.bg-cocinero .stock-nombre {
    grid-column: 1 / -1;
    font-size: 19px;
}
body.bg-cocinero .stock-toggle {
    display: flex;
    align-items: center;
    gap: 14px;
    min-height: 58px;
    padding: 10px 14px;
    background: #fff;
    border: 2px solid #cbd5e1;
    border-radius: 10px;
    color: #334155;
    font-size: 18px;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
}
body.bg-cocinero .stock-toggle input[type="checkbox"] {
    flex: 0 0 auto;
    width: 30px;
    height: 30px;
    accent-color: #2563eb;
    cursor: pointer;
}
body.bg-cocinero .stock-toggle:has(input:checked) {
    border-color: #10b981;
    background: #ecfdf5;
    color: #065f46;
}
body.bg-cocinero .stock-item input[type="number"] {
    min-height: 58px;
    padding: 14px;
    border-radius: 10px;
    font-size: 22px;
    font-weight: 700;
    text-align: center;
}
body.bg-cocinero .stock-item .btn {
    min-height: 58px;
    padding: 14px 30px;
    border-radius: 10px;
    font-size: 19px;
}

/* --- Tablets en vertical / pantallas angostas --- */
@media (max-width: 720px) {
    body.bg-cocinero .navbar { padding: 16px 18px; }
    body.bg-cocinero .navbar h2 { font-size: 24px; }
    body.bg-cocinero .nav-links a,
    body.bg-cocinero .nav-links .nav-btn { padding: 12px 20px; font-size: 18px; }
    body.bg-cocinero .grid-cards { padding: 18px; grid-template-columns: 1fr; gap: 20px; }
    body.bg-cocinero .card-title { font-size: 23px; }
    body.bg-cocinero .stock-grid { grid-template-columns: 1fr; }
    body.bg-cocinero .stock-item { grid-template-columns: 1fr; }
    body.bg-cocinero .stock-item .btn { width: 100%; }
}
