/* --- Variables y Reset --- */
:root {
    --bg-app: #f3f4f6;
    --bg-panel: #ffffff;
    --color-primary: #6366f1;
    --color-primary-dark: #4f46e5;
    --color-success: #10b981;
    --color-danger: #ef4444;
    --color-warning: #f59e0b;
    --color-text: #111827;
    --color-text-muted: #6b7280;
    --border-color: #e5e7eb;
    
    --border-radius-lg: 16px;
    --border-radius-md: 12px;
    --border-radius-sm: 8px;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --font-family: 'Inter', 'Roboto', sans-serif;
}

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

* { box-sizing: border-box; margin: 0; padding: 0; }
body { 
    background-color: var(--bg-app); 
    color: var(--color-text); 
    font-family: var(--font-family);
    height: 100vh; 
    overflow: hidden; 
    line-height: 1.4; /* Reducido ligeramente para compactar */
}

/* LAYOUT GRID PRINCIPAL */
#pos-layout {
    display: grid;
    grid-template-columns: 1.3fr 1fr; 
    height: 100vh;
    gap: 0;
}

/* =========================================
   PANEL IZQUIERDO (Entradas) - Sin cambios mayores
   ========================================= */
.panel-inputs {
    padding: 20px;
    overflow-y: auto; 
    border-right: 1px solid var(--border-color);
    background-color: var(--bg-app);
}

.pos-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 20px;
}
.pos-header h2 { 
    color: var(--color-primary); 
    font-size: 1.5rem; 
    font-weight: 700;
    display: flex; align-items: center; gap: 10px; 
}
.admin-link { 
    text-decoration: none; color: var(--color-text-muted); 
    display: flex; align-items: center; gap: 6px; 
    font-weight: 500; padding: 6px 10px;
    border-radius: var(--border-radius-sm); transition: all 0.2s;
}
.admin-link:hover { background-color: #e5e7eb; color: var(--color-text); }

.card-input-section {
    background: var(--bg-panel);
    border-radius: var(--border-radius-md);
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
}

.section-header {
    font-size: 1.1rem; font-weight: 600; color: var(--color-text);
    margin-bottom: 15px; padding-bottom: 10px; border-bottom: 2px solid var(--bg-app);
    display: flex; align-items: center; gap: 8px;
}
.section-header i { color: var(--color-primary); font-size: 1.3rem; }
.cash-header i { color: var(--color-success); }
.bank-header i { color: var(--color-primary); }
.extra-header i { color: var(--color-warning); }

.input-row { display: flex; gap: 15px; flex-wrap: wrap; }
.input-block { flex: 1; min-width: 200px; }
.input-block label { 
    display: block; font-size: 0.85rem; font-weight: 500;
    color: var(--color-text-muted); margin-bottom: 5px; 
}

.input-group { display: flex; gap: 5px; }
.input-group input, .input-full, .mini-input, .input-combo input, .input-combo select { 
    padding: 10px; 
    border: 1px solid var(--border-color); 
    border-radius: var(--border-radius-sm); 
    font-size: 0.95rem; 
    width: 100%;
    transition: border-color 0.2s;
}
.input-group input:focus, .input-full:focus { border-color: var(--color-primary); outline: none; }
.input-group input[type="number"] { font-weight: 600; width: 110px; text-align: right; }

.btn-icon {
    width: 42px; height: 42px; border: none; border-radius: var(--border-radius-sm); 
    cursor: pointer; color: white; display: flex; align-items: center; justify-content: center;
    transition: all 0.2s; box-shadow: var(--shadow-sm);
}
.btn-icon:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn-green { background-color: var(--color-success); }
.btn-red { background-color: var(--color-danger); }

/* GRID DE BANCOS */
.bank-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px;
}
.bank-card {
    padding: 12px; border-radius: var(--border-radius-md); border: 1px solid var(--border-color);
    text-align: center; background: #ffffff;
    transition: all 0.2s;
}
.bank-card:hover { border-color: var(--color-primary); }
.bank-card h4 { margin-bottom: 8px; font-size: 0.9rem; font-weight: 600; }
.mini-input { margin-bottom: 5px; font-size: 0.9rem; padding: 8px; }
.btn-full {
    width: 100%; padding: 8px; border: none; border-radius: var(--border-radius-sm);
    font-size: 0.85rem; font-weight: 600; color: white; cursor: pointer;
}

.yape-style { border-top: 3px solid #a855f7; } .yape-style h4 { color: #a855f7; } .yape-style .btn-full { background-color: #a855f7; }
.plin-style { border-top: 3px solid #ef4444; } .plin-style h4 { color: #ef4444; } .plin-style .btn-full { background-color: #ef4444; }
.card-style { border-top: 3px solid #3b82f6; } .card-style h4 { color: #3b82f6; } .card-style .btn-full { background-color: #3b82f6; }
.transfer-style { border-top: 3px solid #6b7280; } .transfer-style h4 { color: #6b7280; } .transfer-style .btn-full { background-color: #6b7280; }

.extra-section { border: none; padding: 0; background: none; box-shadow: none; }
.extra-header { 
    background: var(--bg-panel); padding: 12px 20px; border-radius: var(--border-radius-md);
    cursor: pointer; list-style: none; display: flex; justify-content: space-between;
    box-shadow: var(--shadow-sm); border: 1px solid var(--border-color);
}
.extra-content {
    background: var(--bg-panel); padding: 20px; 
    border-bottom-left-radius: var(--border-radius-md); border-bottom-right-radius: var(--border-radius-md);
    box-shadow: var(--shadow-sm); border: 1px solid var(--border-color); border-top: none;
}
.extra-row { display: flex; gap: 15px; width: 100%; flex-wrap: wrap; }
.extra-block { flex: 1; min-width: 200px; padding: 15px; border-radius: var(--border-radius-md); border: 1px solid transparent; }
.descuento-block { background-color: #fef2f2; border-color: #fee2e2; }
.extra-ingreso-block { background-color: #ecfdf5; border-color: #d1fae5; }
.extra-block label { font-weight: 600; margin-bottom: 8px; display: block; font-size: 0.9rem; }
.input-full { margin-bottom: 10px; }
.input-combo { display: flex; gap: 5px; align-items: center; }
.input-combo input[type="number"] { width: 90px; font-weight: 600; }
.input-combo select { flex-grow: 1; cursor: pointer; }


/* =========================================
   PANEL DERECHO (RESUMEN OPTIMIZADO)
   ========================================= */
.panel-summary {
    background-color: #1e293b;
    color: white;
    padding: 20px; /* Reducido de 24 a 20 para ganar espacio */
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: -4px 0 15px rgba(0,0,0,0.1);
}

/* Elementos fijos arriba */
.summary-top-fixed { flex-shrink: 0; }

.kpi-main-highlight {
    background: linear-gradient(135deg, var(--color-success) 0%, #059669 100%);
    color: white;
    /* OPTIMIZADO: Padding más pequeño */
    padding: 15px; 
    border-radius: var(--border-radius-lg);
    text-align: center;
    margin-bottom: 15px; /* Menos margen */
    box-shadow: var(--shadow-lg);
}
.kpi-main-highlight small { 
    text-transform: uppercase; font-weight: 600; opacity: 0.9; 
    letter-spacing: 1px; font-size: 0.75rem; /* Texto más pequeño */
}
/* OPTIMIZADO: Fuente más pequeña (antes 3.5rem) */
.kpi-value-huge { font-size: 2.5rem; font-weight: 800; line-height: 1.1; margin-top: 5px; }

.kpi-secondary-row {
    display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 15px;
}
.kpi-card-secondary {
    background: rgba(255,255,255,0.08);
    /* OPTIMIZADO: Menos padding */
    padding: 10px;
    border-radius: var(--border-radius-md);
    text-align: center;
    border: 1px solid rgba(255,255,255,0.1);
    backdrop-filter: blur(5px);
}
.kpi-card-secondary small { color: rgba(255,255,255,0.7); font-size: 0.75rem; }
.kpi-value-medium { font-size: 1.3rem; font-weight: 700; margin-top: 2px; }

/* MINI CARDS GRID */
.mini-cards-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px; /* Menos espacio entre tarjetas */
    margin-bottom: 15px; /* Menos margen inferior */
}
.mini-card {
    background: rgba(255,255,255,0.05);
    padding: 8px 4px; /* Muy compacto */
    border-radius: var(--border-radius-sm);
    text-align: center;
    border: 1px solid rgba(255,255,255,0.1);
    transition: background 0.2s;
}
.mini-card:hover { background: rgba(255,255,255,0.1); }
.mini-card small { display: block; font-size: 0.7rem; color: rgba(255,255,255,0.6); margin-bottom: 2px; }
.mini-val { font-size: 0.9rem; font-weight: 600; display: block; }
.text-red { color: #fca5a5; }

/* TICKET CONTAINER (Historial) - SE ESTIRA AUTOMÁTICAMENTE */
.ticket-container {
    flex: 1; /* Esto hace que ocupe TODO el espacio sobrante */
    overflow-y: auto; /* Scroll interno */
    min-height: 0; /* Vital para flexbox */
    background: var(--bg-panel); 
    color: var(--color-text); 
    border-radius: var(--border-radius-md); 
    padding: 12px;
    margin-bottom: 12px;
    box-shadow: var(--shadow-md);
}
.ticket-container h3 { 
    font-size: 0.9rem; font-weight: 700; color: var(--color-text-muted);
    border-bottom: 1px solid var(--border-color); 
    padding-bottom: 8px; margin-bottom: 8px; 
    text-align: center; text-transform: uppercase; 
    position: sticky; top: 0; background: var(--bg-panel); z-index: 10; 
}

/* Estilos de los items del historial */
.history-group { border-bottom: 1px solid var(--border-color); margin-bottom: 6px; }
.history-header { 
    padding: 10px; cursor: pointer; font-weight: 600; font-size: 0.85rem; 
    display: flex; justify-content: space-between; align-items: center; 
    border-radius: var(--border-radius-sm); transition: all 0.2s; list-style: none; 
}
.history-header:hover { background-color: var(--bg-app); }

.header-green { color: var(--color-success); } 
.header-red { color: var(--color-danger); } 
.header-purple { color: #8b5cf6; }
.header-pink { color: #ec4899; } 
.header-blue { color: #3b82f6; } 
.header-gray { color: #6b7280; }
.header-orange { color: var(--color-warning); }

.history-header::after { content: 'expand_more'; font-family: 'Material Icons Outlined'; font-size: 1.2rem; transition: transform 0.2s; }
details[open] .history-header::after { transform: rotate(180deg); }

.count-badge { 
    background: var(--border-color); color: var(--color-text); 
    font-size: 0.7rem; font-weight: 600; padding: 2px 6px; 
    border-radius: 10px; margin-left: auto; margin-right: 8px; 
}

.feed-list { padding: 6px 8px 12px 8px; background: #f9fafb; border-radius: 0 0 var(--border-radius-sm) var(--border-radius-sm); }
.feed-item { 
    background: white; padding: 8px 10px; 
    border: 1px solid var(--border-color); border-radius: var(--border-radius-sm); 
    margin-bottom: 6px; display: flex; justify-content: space-between; align-items: center; 
    box-shadow: var(--shadow-sm);
}
.feed-item.negative span.amount { color: var(--color-danger); }
.feed-item.positive span.amount { color: var(--color-success); font-weight: 700; }
.feed-info { display: flex; flex-direction: column; }
.feed-info strong { font-size: 0.85rem; }
.amount { font-size: 0.85rem; }

/* FOOTER DE ACCIONES */
.action-footer { flex-shrink: 0; display: flex; flex-direction: column; gap: 10px; }
.btn-big-save { 
    background-color: var(--color-primary); color: white; border: none; 
    padding: 12px; border-radius: var(--border-radius-md); 
    font-size: 1rem; font-weight: 700; cursor: pointer; 
    display: flex; justify-content: center; align-items: center; gap: 8px; 
    width: 100%; transition: all 0.2s; box-shadow: var(--shadow-md);
}
.btn-big-save:hover { background-color: var(--color-primary-dark); transform: translateY(-2px); }
.btn-text-reset { 
    background: none; border: none; color: rgba(255,255,255,0.5); 
    cursor: pointer; font-size: 0.8rem; 
}
.btn-text-reset:hover { color: white; text-decoration: underline; }

/* --- MEDIA QUERIES PARA PANTALLAS PEQUEÑAS (Laptops) --- */
/* Si la altura es menor a 800px (típico laptop), compactamos aún más */
@media (max-height: 800px) {
    .panel-summary { padding: 15px; }
    .kpi-main-highlight { padding: 10px; margin-bottom: 10px; }
    .kpi-value-huge { font-size: 2rem; margin-top: 2px; }
    .kpi-card-secondary { padding: 8px; }
    .kpi-value-medium { font-size: 1.1rem; }
    .mini-card { padding: 6px 2px; }
    .btn-big-save { padding: 10px; font-size: 0.95rem; }
}

/* =========================================
   MODALES Y ADMIN
   ========================================= */
.modal-overlay, .admin-overlay { 
    position: fixed; top: 0; left: 0; width: 100%; height: 100%; 
    background: rgba(0, 0, 0, 0.5); backdrop-filter: blur(4px);
    display: none; justify-content: center; align-items: center; z-index: 2000; 
}
body.modal-open .modal-overlay { display: flex; }
.admin-overlay:not(.hidden) { display: flex; }

.modal-container, .admin-content { 
    background: var(--bg-panel); padding: 24px; 
    border-radius: var(--border-radius-lg); width: 90%; max-width: 600px; 
    box-shadow: var(--shadow-lg); animation: fadeIn 0.2s ease-out; 
}
.modal-header, .admin-header-top { 
    display: flex; justify-content: space-between; align-items: center; 
    border-bottom: 1px solid var(--border-color); padding-bottom: 12px; margin-bottom: 20px; 
}
.modal-header h3, .admin-header-top h2 { margin: 0; color: var(--color-text); font-size: 1.4rem; }
.modal-close-btn { background: none; border: none; font-size: 1.5rem; cursor: pointer; color: var(--color-text-muted); }

.modal-body .form-group { margin-bottom: 15px; }
.modal-body label { display: block; margin-bottom: 5px; font-weight: 600; color: var(--color-text); }
.modal-body input[type="text"] { padding: 10px; border: 1px solid var(--border-color); border-radius: var(--border-radius-sm); font-size: 1rem; width: 100%; }
.modal-footer { text-align: right; margin-top: 20px; }
.modal-footer .btn-primary, .admin-content .btn-primary { 
    padding: 10px 20px; background-color: var(--color-primary); color: white; 
    border: none; border-radius: var(--border-radius-sm); font-weight: 600; 
    cursor: pointer; transition: background-color 0.2s;
}

.admin-content { max-height: 90vh; overflow-y: auto; }
.admin-content input, .admin-content select { width: 100%; padding: 10px; border: 1px solid var(--border-color); border-radius: var(--border-radius-sm); margin-bottom: 10px; }
.btn-secondary { padding: 8px 16px; background-color: white; border: 1px solid var(--border-color); color: var(--color-text); border-radius: var(--border-radius-sm); cursor: pointer; font-weight: 500; }

#filter-results-list { margin-top: 15px; max-height: 300px; overflow-y: auto; border: 1px solid var(--border-color); border-radius: var(--border-radius-md); background: var(--bg-app); padding: 10px; }
.report-item { 
    background: white; padding: 12px; border-bottom: 1px solid var(--border-color); 
    display: flex; justify-content: space-between; align-items: center; 
    transition: all 0.2s; cursor: pointer; margin-bottom: 6px; 
    border-radius: var(--border-radius-sm); border: 1px solid transparent;
    box-shadow: var(--shadow-sm);
}
.report-item:hover { border-color: var(--color-primary); box-shadow: var(--shadow-md); }

/* BOTÓN VER (ADMIN) */
.report-item button {
    padding: 6px 12px;
    background-color: white; 
    color: var(--color-primary); 
    border: 1px solid var(--color-primary); 
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    display: flex; align-items: center; gap: 5px;
    transition: all 0.2s ease-in-out;
    box-shadow: var(--shadow-sm);
}
.report-item button:hover {
    background-color: var(--color-primary);
    color: white;
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}
.report-item button i { font-size: 1rem; }

.hidden-log { display: none; }
.hidden { display: none !important; }
@keyframes fadeIn { from { opacity: 0; transform: scale(0.95); } to { opacity: 1; transform: scale(1); } }

@media (max-width: 900px) {
    #pos-layout { grid-template-columns: 1fr; overflow-y: auto; display: block; }
    .panel-summary { height: auto; overflow: visible; box-shadow: none; }
    .ticket-container { height: 400px; }
}