/* =========================================
   GENERAL LAYOUT
   ========================================= */
#cpos-mesero-app, #cpos-kitchen-screen, #cpos-cashier-screen {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #f4f4f4;
    padding: 20px;
    border-radius: 8px;
    max-width: 100%;
    margin: 0 auto;
}

.hidden { display: none !important; }

/* Botones Generales */
.btn-primary { background: #0073aa; color: white; border: none; padding: 10px 20px; cursor: pointer; border-radius: 4px; }
.btn-secondary { background: #555; color: white; border: none; padding: 10px 20px; cursor: pointer; border-radius: 4px; }
.btn-del { background: #d63638; color: white; border: none; padding: 5px 10px; cursor: pointer; border-radius: 4px; margin-left: 5px; }
.btn-adv { background: #0073aa; color: white; border: none; padding: 5px 10px; cursor: pointer; border-radius: 4px; }

/* =========================================
   MESERO UI
   ========================================= */
.cpos-header { margin-bottom: 20px; }
.cpos-header select { padding: 10px; font-size: 16px; width: 100%; max-width: 300px; }

/* Tabs Zonas */
.cpos-zones { display: flex; gap: 10px; margin-bottom: 20px; overflow-x: auto; }
.zone-tab {
    padding: 10px 20px;
    background: #e0e0e0;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
}
.zone-tab.active { background: #0073aa; color: white; }

/* Grid Mesas */
.cpos-tables-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 15px;
}
.cpos-table-card {
    background: white;
    padding: 20px;
    border-radius: 8px;
    text-align: center;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    transition: transform 0.2s;
}
.cpos-table-card:active { transform: scale(0.95); }
.cpos-table-card.libre { border-top: 5px solid #46b450; } /* Verde */
.cpos-table-card.ocupada { border-top: 5px solid #dc3232; background: #fff0f0; } /* Rojo */

/* Modal Productos */
.cpos-modal {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.6);
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
}
.modal-content {
    background: white;
    width: 90%;
    max-width: 900px;
    height: 90vh;
    border-radius: 8px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    position: relative;
}
/* Modal Pequeño (Detalles) */
.modal-content.small-modal {
    max-width: 400px;
    height: auto;
    padding: 30px;
    gap: 15px;
}
.modal-content.small-modal textarea { width: 100%; height: 80px; padding: 10px; }
.modal-content.small-modal input { width: 100%; padding: 10px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 10px; }

.close-modal {
    position: absolute; top: 10px; right: 20px;
    font-size: 30px; cursor: pointer;
}

.cpos-menu-layout {
    display: grid;
    grid-template-columns: 150px 1fr 280px; /* Cats | Prods | Cart */
    gap: 20px;
    height: 100%;
    overflow: hidden;
}

.menu-cats { display: flex; flex-direction: column; gap: 10px; overflow-y: auto; }
.cat-btn { padding: 15px; text-align: left; background: #eee; border: none; cursor: pointer; }
.cat-btn.active { background: #0073aa; color: white; }

.menu-products {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 10px;
    overflow-y: auto;
    align-content: start;
}
.product-card {
    background: white;
    border: 1px solid #ddd;
    padding: 10px;
    text-align: center;
    cursor: pointer;
}
.product-card:hover { background: #f9f9f9; border-color: #0073aa; }

.current-order {
    border-left: 2px solid #eee;
    padding-left: 20px;
    display: flex;
    flex-direction: column;
}
.current-order ul { list-style: none; padding: 0; flex-grow: 1; overflow-y: auto; }
.current-order li { 
    display: flex; justify-content: space-between; 
    border-bottom: 1px solid #eee; padding: 10px 0; 
    align-items: flex-start;
}
.cart-item-info { font-size: 14px; }
.cart-note { font-size: 11px; color: #666; font-style: italic; }
.cart-extra { font-size: 11px; color: #0073aa; font-weight: bold; }
.order-total { font-size: 18px; font-weight: bold; text-align: right; margin: 10px 0; }

/* =========================================
   COCINA UI
   ========================================= */
#cpos-kitchen-screen { display: grid; grid-template-columns: 300px 1fr; gap: 20px; height: 80vh; }
.kitchen-sidebar { background: #e5e5e5; padding: 10px; overflow-y: auto; }
.kitchen-order-card {
    background: white; padding: 15px; margin-bottom: 10px; cursor: pointer;
    border-left: 4px solid #ccc;
}
.kitchen-order-card.urgent { border-left-color: #d63638; }

.kitchen-detail ul { list-style: none; padding: 0; }
.k-item {
    display: flex; justify-content: space-between; align-items: center;
    padding: 15px; background: white; margin-bottom: 5px; border-bottom: 1px solid #eee;
}
.row-cancelled { background-color: #ffeaea; opacity: 0.6; }
.row-cancelled .name { text-decoration: line-through; }

.k-info { display: flex; flex-direction: column; }
.k-note { font-size: 12px; color: #d63638; }

.st-pen { color: red; font-weight: bold; }
.st-proc { color: orange; font-weight: bold; }
.st-done { color: green; font-weight: bold; }
.st-cancel { color: #999; font-weight: bold; }

/* =========================================
   CAJA & IMPRESIÓN (58mm)
   ========================================= */
.cashier-tables { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 20px; }
.cashier-table-btn { padding: 15px; font-size: 16px; cursor: pointer; background: #fff; border: 1px solid #ccc; }
.cashier-table-btn:hover { background: #e0f0ff; border-color: #0073aa; }

.ticket {
    background: white;
    width: 280px; /* Aprox 58mm + márgenes visuales */
    padding: 10px;
    border: 1px dashed #ccc;
    font-family: 'Courier New', Courier, monospace; /* Monospace para tickets */
    font-size: 12px;
    margin-bottom: 20px;
}
.ticket-header { text-align: center; margin-bottom: 10px; }
.ticket-header h4 { margin: 0; font-size: 14px; text-transform: uppercase; }
.ticket-header p { margin: 5px 0; font-size: 10px; }
.ticket-info p { margin: 2px 0; }
.ticket-items { width: 100%; border-collapse: collapse; margin-top: 10px; border-top: 1px dashed #000; border-bottom: 1px dashed #000; }
.ticket-items th { text-align: left; font-size: 10px; }
.ticket-items td { padding: 4px 0; font-size: 11px; }
.ticket-total { text-align: right; margin-top: 10px; font-size: 14px; }
.ticket-footer { text-align: center; margin-top: 15px; font-size: 10px; }

/* ESTILOS DE IMPRESIÓN - CRUCIAL */
@media print {
    /* Ocultar todo lo que no sea el ticket */
    body * {
        visibility: hidden;
        height: 0;
        overflow: hidden;
    }

    /* Mostrar solo el área del ticket */
    #ticket-print-area, #ticket-print-area * {
        visibility: visible;
        height: auto;
        overflow: visible;
    }

    /* Posicionar el ticket en la esquina superior izquierda del papel */
    #ticket-print-area {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%; /* Ocupa el ancho del papel de 58mm */
        border: none;
        padding: 0;
        margin: 0;
    }

    /* Resetear márgenes de página */
    @page {
        size: 58mm auto; /* Intentar forzar tamaño si el navegador soporta */
        margin: 0;
    }
    
    /* Asegurar color negro puro */
    * { color: black !important; background: transparent !important; box-shadow: none !important; }
}