html, body {
    font-family: -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Helvetica, Arial, sans-serif;
    margin: 0;
    background: #F4F1EC;
    color: #1A1A1A;
    -webkit-font-smoothing: antialiased;
}
* { box-sizing: border-box; }

h2 { margin: 0 0 12px 0; font-size: 22px; color: #8B1538; }
h3 { margin: 0 0 8px 0; font-size: 16px; color: #2D5A45; }

.muted { color: #8A8580; font-size: 12px; }
.center { text-align: center; }
.ok { color: #2D5A45; margin-left: 8px; font-weight: 600; }

.card {
    background: white;
    border-radius: 8px;
    padding: 14px;
    margin-bottom: 14px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.page-header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

input, select, textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #d6d2cc;
    border-radius: 6px;
    font-size: 15px;
    background: white;
    margin-bottom: 8px;
    font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: 2px solid #8B1538; outline-offset: -1px; }

input.search { margin-bottom: 12px; }

button {
    padding: 10px 14px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    margin-right: 6px;
}
button.primary { background: #8B1538; color: white; }
button.secondary { background: #2D5A45; color: white; }
button.neutral { background: #8A8580; color: white; }
button.danger { background: #B8336A; color: white; }
button:disabled { opacity: 0.5; }

.list { list-style: none; padding: 0; margin: 0; }
.list-item {
    background: white;
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    cursor: pointer;
}
.list.short .list-item { padding: 8px 12px; }
.list-item .row { display: flex; gap: 8px; align-items: center; margin-top: 6px; }
.list-item .row input { flex: 1; margin: 0; }
.list-item .subtotal { font-weight: 600; min-width: 90px; text-align: right; }

.badge-pending {
    background: #D4A017;
    color: white;
    padding: 1px 6px;
    border-radius: 10px;
    font-size: 10px;
    margin-left: 6px;
    vertical-align: middle;
}

.alert {
    background: #B8336A;
    color: white;
    padding: 10px;
    border-radius: 6px;
    margin-bottom: 12px;
}

.form label { display: block; font-size: 12px; font-weight: 600; margin-top: 8px; margin-bottom: 4px; }

.actions {
    display: flex;
    gap: 6px;
    margin-top: 16px;
    justify-content: flex-end;
    flex-wrap: wrap;
}

.totales { margin-top: 12px; padding-top: 12px; border-top: 1px solid #eee; }
.totales > div { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.totales > div input { max-width: 120px; margin: 0; }
.totales .total { background: #2D5A45; color: white; padding: 8px 12px; border-radius: 6px; margin-top: 6px; font-size: 16px; }
.totales .total strong { font-size: 18px; }

.link-danger { background: none; color: #8B1538; padding: 0 6px; font-size: 18px; float: right; }

/* File input estilizado como botón */
.file-input { display: inline-block; position: relative; cursor: pointer; }
.file-input input[type=file] {
    position: absolute; left: 0; top: 0;
    width: 100%; height: 100%;
    opacity: 0;
    cursor: pointer;
}
.file-input-button {
    display: inline-block;
    padding: 12px 20px;
    background: #2D5A45;
    color: white;
    border-radius: 6px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
}
.file-input:active .file-input-button { opacity: 0.85; }

/* Punto de Venta para eventos (feature 011) — carta con botones grandes,
   aptos para tocar con el dedo en una tablet (RF-003). */
.pos-carta-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 10px;
    margin: 12px 0;
}
.pos-boton-producto {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    min-height: 84px;
    padding: 10px 6px;
    background: #2D5A45;
    color: white;
    border: none;
    border-radius: 10px;
    font-weight: 600;
    font-size: 14px;
    text-align: center;
    cursor: pointer;
}
.pos-boton-producto:disabled { background: #c9c5bd; color: #6b6a67; cursor: not-allowed; }
.pos-boton-producto .precio { font-weight: 400; font-size: 12px; opacity: 0.85; }
.pos-boton-producto .remanente { font-size: 11px; opacity: 0.85; }
/* Medios de pago: mismo botón que la carta, en el color de "cobrar". */
.pos-boton-cobro { background: #8B1538; font-size: 16px; }
/* Feature 043: accesos directos a los descuentos del evento (hacen wrap en .actions) */
.pos-descuento-rapido { border: 1px dashed #8B1538; color: #8B1538; }

.pos-comanda-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 0;
    border-bottom: 1px solid #eee;
}
.pos-comanda-item .cantidad-controles { display: flex; align-items: center; gap: 6px; }
.pos-comanda-item .cantidad-controles button {
    width: 30px; height: 30px; padding: 0; margin: 0;
    border-radius: 50%; font-size: 16px; line-height: 1;
}

/* Observaciones de la comanda (feature 039): etiquetas, editor con accesos rápidos y
   sugerencias, y su marca en el tablero. Botones grandes: se tocan con el dedo. */
.pos-obs-etiquetas { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 4px 0 8px; }
.pos-obs-etiqueta {
    display: inline-flex; align-items: center; gap: 4px;
    background: #FFF4E0; color: #6B4400; border: 1px solid #F0D4A0;
    border-radius: 14px; padding: 2px 4px 2px 10px; font-size: 13px; font-weight: 600;
}
.pos-obs-etiqueta button {
    background: transparent; color: inherit; border: none; margin: 0;
    padding: 0 6px; font-size: 14px; line-height: 1; min-height: 0;
}
.pos-obs-editor { background: #FAFAFA; border: 1px solid #eee; border-radius: 8px; padding: 8px; margin: 4px 0 8px; }
.pos-obs-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.pos-obs-chip {
    background: #fff; color: #8B1538; border: 1px solid #8B1538;
    border-radius: 16px; padding: 8px 12px; margin: 0; font-size: 14px;
}
.pos-obs-campo { display: flex; gap: 6px; }
.pos-obs-campo input { flex: 1; min-width: 0; margin: 0; }
.pos-obs-campo button { margin: 0; }
.pos-obs-sugerencias {
    display: flex; flex-direction: column; margin-top: 4px;
    background: #fff; border: 1px solid #ddd; border-radius: 6px; overflow: hidden;
}
.pos-obs-sugerencias button {
    background: #fff; color: #222; border: none; border-bottom: 1px solid #eee;
    border-radius: 0; margin: 0; padding: 10px 12px; text-align: left; font-size: 15px;
}
.pos-obs-sugerencias button:last-child { border-bottom: none; }
.pos-obs-sugerencias .pos-obs-nueva { color: #8B1538; font-weight: 600; }
.pos-obs-tablero { color: #B85C00; }

/* Tablero de estados de comandas (feature 012) — pantalla pública de 3
   columnas, pensada para un monitor/TV, y pantalla de gestión del staff. */
.pos-tablero {
    display: grid;
    /* La cantidad de columnas la pone PosPantallaPublica (inline), según la
       configuración de la pantalla. */
    grid-template-columns: 1fr 1fr 1fr;
    gap: 16px;
    height: calc(100vh - 90px);
}
.pos-columna {
    background: white;
    border-radius: 10px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}
.pos-columna h2 {
    text-align: center;
    font-size: 22px;
    margin-bottom: 16px;
    padding-bottom: 10px;
    border-bottom: 3px solid currentColor;
}
.pos-columna.pendientes h2 { color: #8A8580; }
.pos-columna.cocinando h2 { color: #C2571A; }
.pos-columna.para-armar h2 { color: #6E4A9E; }
.pos-columna.preparacion h2 { color: #D4A017; }
.pos-columna.listos h2 { color: #2D5A45; }
.pos-columna.entregados h2 { color: #3B5B8C; }

.pos-pedido-caja {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
}
.pos-pedido-numero {
    background: #F4F1EC;
    border: 3px solid #8A8580;
    border-radius: 10px;
    padding: 18px 8px;
    text-align: center;
    font-size: 26px;
    font-weight: 800;
    cursor: grab;
    /* Necesario para que el navegador no tome el gesto de tocar/arrastrar
       como un scroll de la página — si no, en una tablet el drag-and-drop
       (feature 012, pantalla pública interactiva) compite con el scroll
       nativo y ninguno de los dos anda bien. */
    touch-action: none;
    user-select: none;
}
.pos-columna.cocinando .pos-pedido-numero { border-color: #C2571A; }
.pos-columna.para-armar .pos-pedido-numero { border-color: #6E4A9E; }
.pos-columna.preparacion .pos-pedido-numero { border-color: #D4A017; }
.pos-columna.listos .pos-pedido-numero { border-color: #2D5A45; background: #eafaf1; animation: pos-pulso 1.2s infinite; }
.pos-columna.entregados .pos-pedido-numero { border-color: #3B5B8C; opacity: 0.75; }
/* Detalle del pedido debajo del número: lo que pidió el cliente. */
.pos-pedido-num { line-height: 1.1; }
.pos-pedido-items {
    list-style: none;
    margin: 8px 0 0;
    padding: 6px 0 0;
    border-top: 1px solid rgba(0,0,0,0.12);
    font-size: 15px;
    font-weight: 600;
    text-align: left;
    line-height: 1.3;
}
.pos-pedido-items li { overflow-wrap: anywhere; }
.pos-pedido-numero.arrastrando {
    cursor: grabbing;
    opacity: 0.9;
    box-shadow: 0 10px 24px rgba(0,0,0,0.35);
    animation: none;
}

/* Mobile (feature 012): 3 columnas lado a lado quedan angostísimas en un
   celu — se apilan una debajo de la otra, cada una con su propio scroll, en
   vez de comprimir los números de pedido hasta hacerlos ilegibles. */
@media (max-width: 800px) {
    .pos-tablero {
        grid-template-columns: 1fr !important; /* pisa el inline de la cantidad de columnas */
        height: auto;
        gap: 12px;
    }
    .pos-columna {
        max-height: 42vh;
    }
    .pos-pedido-caja {
        grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
        gap: 8px;
    }
    .pos-pedido-numero {
        font-size: 20px;
        padding: 14px 6px;
    }
}

@keyframes pos-pulso {
    0%, 100% { box-shadow: 0 0 0 0 rgba(45,90,69,0.5); }
    50% { box-shadow: 0 0 0 10px rgba(45,90,69,0); }
}

/* Pantalla de gestión (staff) — lista de comandas con botones de estado */
.pos-gestion-item {
    background: white;
    border-radius: 10px;
    padding: 14px;
    margin-bottom: 10px;
    border-left: 6px solid #8A8580;
}
.pos-gestion-item.cocinando { border-left-color: #C2571A; }
.pos-gestion-item.para-armar { border-left-color: #6E4A9E; }
.pos-gestion-item.preparacion { border-left-color: #D4A017; }
.pos-gestion-item.listos { border-left-color: #2D5A45; }
.pos-gestion-item.entregados { border-left-color: #8A8580; opacity: 0.6; }
.pos-gestion-item.cancelado { border-left-color: #B8336A; opacity: 0.6; }
.pos-gestion-item .estado-badge {
    display: inline-block;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 10px;
    background: #eee;
    margin-left: 8px;
}
.pos-gestion-item .items-resumen { font-size: 12px; color: #8A8580; margin: 4px 0; }
.pos-gestion-item .actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
}
.pos-gestion-item .actions button {
    font-size: 12px;
    padding: 6px 10px;
    flex: 1 1 auto;
    min-width: 90px;
    margin: 0;
}
.pos-gestion-item .actions button.activo { outline: 3px solid #1A1A1A; }

/* Mobile (feature 012): botones más grandes y en grilla 2x2, más fáciles de
   tocar con el dedo que la fila que se envuelve sola en pantallas chicas. */
@media (max-width: 600px) {
    .pos-gestion-item .actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }
    .pos-gestion-item .actions button {
        font-size: 14px;
        font-weight: 700;
        padding: 14px 8px;
        min-height: 48px;
        min-width: 0;
    }
}

.modal-back {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.4);
    display: flex; align-items: flex-end;
    z-index: 100;
}
.modal {
    background: white;
    width: 100%;
    max-height: 85dvh;
    overflow-y: auto;
    border-radius: 12px 12px 0 0;
    padding: 16px;
}
.modal .list { max-height: 50dvh; overflow-y: auto; }

#blazor-error-ui {
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: 0.75rem; top: 0.5rem; }

.loading-progress {
    position: relative; display: block;
    width: 8rem; height: 8rem;
    margin: 20vh auto 1rem auto;
}
.loading-progress circle {
    fill: none; stroke: #e0e0e0; stroke-width: 0.6rem;
    transform-origin: 50% 50%; transform: rotate(-90deg);
}
.loading-progress circle:last-child {
    stroke: #8B1538;
    stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
    transition: stroke-dasharray 0.05s ease-in-out;
}
.loading-progress-text {
    position: absolute; text-align: center; font-weight: bold;
    inset: calc(20vh + 3.25rem) 0 auto 0.2rem;
}
.loading-progress-text:after { content: var(--blazor-load-percentage-text, "Cargando"); }

label.check {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 6px 0;
    cursor: pointer;
}
label.check input[type=checkbox] { width: auto; margin: 0; flex: 0 0 auto; }

/* Pantalla pública: botón de sonido mientras el navegador lo tiene bloqueado. */
#btn-sonido.sonido-inactivo {
    background: #c62828;
    color: #fff;
    animation: pulso-sonido 1.5s ease-in-out infinite;
}
@keyframes pulso-sonido {
    50% { opacity: 0.6; }
}

/* Feature 031: aviso al cliente Cashless por WhatsApp */
.boton-whatsapp {
    display: inline-block;
    margin: 6px 0 2px;
    padding: 8px 14px;
    border-radius: 8px;
    background: #25D366;
    color: #fff;
    font-weight: 700;
    text-decoration: none;
}

/* Feature 038: estado de la conexión con el ERP en las pantallas del Punto de Venta */
.pos-conexion {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 6px;
    padding: 6px 10px;
    border-radius: 6px;
    margin-bottom: 12px;
    font-size: 13px;
    font-weight: 600;
    background: #EDEAE6;
    color: #4A4540;
}
.pos-conexion.conectada { background: #E3EFE8; color: #2D5A45; }
.pos-conexion.enviando { background: #FFF4D6; color: #7A5B00; }
.pos-conexion.sin-conexion { background: #B8336A; color: white; }
.pos-conexion-pendientes { font-weight: 700; }
