:root {
    --primary-color: #f26b21; /* Naranja Fudo-like */
    --primary-hover: #d95a1a;
    --sidebar-bg: #2d3748; /* Oscuro moderno para la barra lateral */
    --sidebar-hover: #4a5568;
    --sidebar-active: #1a202c;
    --bg-color: #f7fafc; /* Gris muy claro para el área de trabajo */
    --surface-color: #ffffff; /* Blanco para tarjetas/mesas */
    --text-dark: #2d3748;
    --text-light: #f7fafc;
    --text-muted: #718096;
    --border-color: #e2e8f0;
    --error-color: #e53e3e;
    --success-color: #38a169;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-dark);
    min-height: 100vh;
    display: flex;
}

/* --- ESTILOS COMPARTIDOS --- */
.btn {
    display: inline-block;
    font-family: 'Inter', sans-serif;
    font-weight: 500;
    text-align: center;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    padding: 10px 16px;
    font-size: 14px;
}

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

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-danger {
    background: var(--error-color);
    color: white;
}

.btn-secondary {
    background: #edf2f7;
    color: #4a5568;
}

.btn-secondary:hover {
    background: #e2e8f0;
}

.btn-small {
    padding: 6px 12px;
    font-size: 12px;
}

/* --- LOGIN (SE MANTIENE INDEPENDIENTE) --- */
.login-body {
    justify-content: center;
    align-items: center;
    background: radial-gradient(circle at top right, #1e293b, #0f172a);
    color: white;
}

.login-container {
    width: 100%;
    max-width: 400px;
    padding: 20px;
}

.glass-effect {
    background: rgba(30, 41, 59, 0.7);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    padding: 40px 30px;
}

.login-body .input-group label { color: #cbd5e1; }
.login-body .input-group input { background: rgba(15, 23, 42, 0.6); color: white; border: 1px solid rgba(255, 255, 255, 0.1); padding: 12px; border-radius: 6px; width: 100%; margin-top: 5px; }

/* --- LAYOUT PRINCIPAL (ESTILO FUDO) --- */
#app {
    display: flex;
    width: 100%;
    height: 100vh;
    overflow: hidden;
}

.sidebar {
    width: 250px;
    background-color: var(--sidebar-bg);
    color: var(--text-light);
    display: flex;
    flex-direction: column;
    transition: all 0.3s;
}

.sidebar-header {
    padding: 20px;
    font-size: 20px;
    font-weight: 600;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--primary-color);
}

.sidebar-menu {
    flex: 1;
    overflow-y: auto;
    padding: 15px 0;
    list-style: none;
}

.menu-item {
    padding: 12px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    color: #a0aec0;
    font-size: 15px;
    transition: 0.2s;
    border-left: 4px solid transparent;
}

.menu-item:hover, .menu-item.active {
    background-color: var(--sidebar-active);
    color: white;
    border-left-color: var(--primary-color);
}

.sidebar-footer {
    padding: 15px 20px;
    border-top: 1px solid rgba(255,255,255,0.1);
    font-size: 13px;
    color: #a0aec0;
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    background-color: var(--bg-color);
}

.topbar {
    background-color: var(--surface-color);
    height: 60px;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.topbar-title {
    font-size: 18px;
    font-weight: 500;
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 15px;
}

.role-badge {
    background-color: #edf2f7;
    color: #4a5568;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
}

.workspace {
    padding: 20px;
    flex: 1;
}

/* --- TARJETAS Y TABLAS --- */
.card {
    background-color: var(--surface-color);
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    padding: 20px;
    border: 1px solid var(--border-color);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 15px;
}

.data-table th, .data-table td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.data-table th {
    background-color: #f8fafc;
    color: var(--text-muted);
    font-weight: 500;
    font-size: 13px;
    text-transform: uppercase;
}

.data-table tr:hover {
    background-color: #f7fafc;
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    font-size: 14px;
}

.form-control {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-family: 'Inter', sans-serif;
    font-size: 14px;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* Utilidades */
.d-none { display: none !important; }
.flex-row { display: flex; gap: 10px; align-items: center; }
.justify-between { justify-content: space-between; }

/* --- RESPONSIVE & MOBILE FIRST --- */

/* Sidebar Toggle para Móviles */
.menu-toggle-btn {
    display: none;
    background: transparent;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-dark);
}

/* POS (Toma de Pedido) */
.pos-container {
    display: flex;
    flex-direction: column; /* Mobile first: stack vertical */
    gap: 15px;
    height: calc(100vh - 100px); /* Ajustado para móviles */
    overflow: hidden; /* Para que el scroll sea interno */
}

.pos-catalog {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 15px;
    background: white;
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    overflow: hidden;
}

.tp-categorias-scroll {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding-bottom: 5px;
    flex-shrink: 0;
    min-height: 50px;
    /* Hide scrollbar for cleaner look on mobile */
    -ms-overflow-style: none;  
    scrollbar-width: none;  
}
.tp-categorias-scroll .btn {
    flex: 0 0 auto;
    white-space: nowrap;
    min-height: 40px;
    padding: 10px 20px;
}
.tp-categorias-scroll::-webkit-scrollbar { display: none; }

.tp-productos-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 10px;
    overflow-y: auto;
    flex: 1;
    padding-right: 5px;
}

.pos-ticket {
    height: 35vh; /* En móvil, el ticket toma un tercio de la pantalla abajo */
    background: #fdfdfd;
    padding: 15px;
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    border-radius: 8px;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
}

.tp-ticket-items {
    flex: 1;
    overflow-y: auto;
    font-size: 13px;
}

.tp-ticket-footer {
    border-top: 2px dashed #ccc;
    padding-top: 10px;
    margin-top: 10px;
}

.tp-total-row {
    display: flex;
    justify-content: space-between;
    font-size: 18px;
    font-weight: bold;
    margin-bottom: 10px;
}

.tp-modal-overlay {
    position: fixed; top:0; left:0; width:100%; height:100%; 
    background: rgba(0,0,0,0.5); 
    z-index: 1000; 
    display:flex; justify-content:center; align-items:center;
}

.tp-modal-content {
    background: white; 
    padding: 20px; 
    border-radius: 12px; 
    width: 400px; 
    max-width: 90%;
    max-height: 90vh;
    overflow-y: auto;
}

/* Modificadores para Checkboxes móviles (más grandes) */
.adic-check {
    width: 20px;
    height: 20px;
}

/* --- MEDIA QUERIES (DESKTOP) --- */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: -250px;
        top: 0;
        bottom: 0;
        z-index: 999;
        box-shadow: 2px 0 10px rgba(0,0,0,0.2);
    }
    .sidebar.show {
        left: 0;
    }
    .menu-toggle-btn {
        display: block;
    }
    .topbar-title {
        font-size: 16px;
    }
    
    /* Las mesas en móvil un poco más chicas para que entren más */
    #mesas-grid {
        grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)) !important;
        gap: 10px !important;
    }
    
    /* En móvil es mejor dejar que toda la página haga scroll naturalmente */
    .pos-container {
        height: auto;
        overflow: visible;
    }
    .pos-catalog, .pos-ticket {
        overflow: visible;
        height: auto;
    }
    .tp-productos-grid, .tp-ticket-items {
        overflow-y: visible;
    }
}

@media (min-width: 769px) {
    .pos-container {
        flex-direction: row; /* Lado a lado en desktop */
        height: calc(100vh - 120px);
    }
    .pos-catalog {
        flex: 2;
    }
    .pos-ticket {
        flex: 1;
        height: auto;
        border-top: none;
        border-left: 1px solid var(--border-color);
        box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    }
}

/* --- TABLERO DELIVERY MOBILE-FIRST (PESTAÑAS) --- */
.delivery-tabs {
    display: none;
    background: #edf2f7;
    border-radius: 8px;
    padding: 4px;
    margin-bottom: 15px;
    gap: 5px;
}

.delivery-tab {
    flex: 1;
    border: none;
    background: transparent;
    padding: 10px 5px;
    font-size: 13px;
    font-weight: 600;
    color: #4a5568;
    border-radius: 6px;
    cursor: pointer;
    text-align: center;
    transition: all 0.2s;
}

.delivery-tab.active {
    background: white;
    color: var(--primary-color);
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.delivery-main-container {
    padding: 20px;
    display: flex;
    flex-direction: column;
    height: calc(100vh - 100px);
    overflow: hidden;
}

.delivery-columns {
    display: flex;
    gap: 20px;
    flex: 1;
    overflow-x: auto;
    padding-bottom: 10px;
    align-items: flex-start;
}

.delivery-column {
    flex: 1;
    min-width: 280px;
    background: #f8fafc;
    border-radius: 8px;
    padding: 15px;
    display: flex;
    flex-direction: column;
    max-height: 100%;
}

@media (max-width: 768px) {
    .delivery-main-container {
        height: auto;
        overflow: visible;
        padding: 10px;
    }

    .delivery-tabs {
        display: flex; /* Mostrar pestañas en móviles */
    }
    
    .delivery-columns {
        flex-direction: column;
        overflow: visible;
        height: auto;
    }

    .delivery-column {
        width: 100%;
        min-width: 0;
        display: none !important; /* Esconder por defecto en móvil */
        height: auto;
        max-height: none;
        overflow: visible;
    }

    .delivery-column.active-tab {
        display: flex !important; /* Mostrar solo la pestaña activa */
    }
}

/* --- FULLSCREEN POS --- */
body.pos-fullscreen .sidebar { display: none !important; }
body.pos-fullscreen .topbar { display: none !important; }
body.pos-fullscreen .workspace { padding: 0 !important; }
body.pos-fullscreen .main-content { padding: 0 !important; }
body.pos-fullscreen .pos-container { height: 100vh !important; overflow: hidden; }

/* Responsive adjustments for pos-container on mobile */
@media (max-width: 768px) {
    body.pos-fullscreen .pos-container {
        display: flex;
        flex-direction: column;
        height: 100vh !important;
        overflow: hidden;
    }
    
    .pos-catalog {
        flex: 1;
        overflow-y: auto !important;
        min-height: 0;
    }

    .pos-ticket {
        flex: 1;
        overflow-y: auto !important;
        min-height: 0;
        border-top: 2px solid #edf2f7;
    }
}
/* --- FUDO STYLE PRODUCTS UI --- */
.fudo-sidebar ul li {
    padding: 12px 15px;
    cursor: pointer;
    border-bottom: 1px solid #2d3748;
    transition: all 0.2s;
    font-size: 14px;
}
.fudo-sidebar ul li:hover {
    background: #2b6cb0;
}
.fudo-sidebar ul li.active {
    background: #3182ce;
    font-weight: bold;
    border-left: 4px solid #ebf8ff;
}

.fudo-table tbody tr {
    border-bottom: 1px solid #e2e8f0;
    transition: background 0.2s;
}
.fudo-table tbody tr:hover {
    background: #f1f5f9;
}
.fudo-table tbody td {
    padding: 12px 15px;
    font-size: 13px;
    color: #4a5568;
    vertical-align: middle;
}

@media (max-width: 768px) {
    .fudo-main-area {
        flex-direction: column !important;
    }
    .fudo-sidebar {
        width: 100% !important;
        flex: 0 0 auto !important;
        overflow-y: hidden !important;
        overflow-x: auto !important;
    }
    .fudo-sidebar ul {
        display: flex;
        flex-direction: row;
    }
    .fudo-sidebar ul li {
        white-space: nowrap;
        border-bottom: none !important;
        border-left: none !important;
        border-bottom: 4px solid transparent !important;
    }
    .fudo-sidebar ul li.active {
        border-bottom: 4px solid #ebf8ff !important;
        background: #3182ce;
    }
    .fudo-table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }
}