/* ==============================================================================
   EL COMERCIANTE - TERMINAL POS & PUNTO DE VENTA (styles.css)
   Inspirado en la interfaz de caja ágil y reportes de utilidades de Aronium
   ============================================================================== */

:root {
    --pos-bg: #0F172A;
    --pos-surface: #1E293B;
    --pos-card: #243248;
    --pos-border: #334155;
    
    --pos-text: #F8FAFC;
    --pos-text-muted: #94A3B8;
    --pos-text-dim: #64748B;
    
    --primary-yellow: #FFCC00;
    --primary-yellow-hover: #EAB308;
    --accent-blue: #3B82F6;
    --success-green: #10B981;
    --danger-red: #EF4444;
    --warning-orange: #F59E0B;
    
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-full: 9999px;
    
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.4);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.5);
    
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

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

body {
    font-family: var(--font);
    background-color: var(--pos-bg);
    color: var(--pos-text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

/* ==============================================================================
   1. LOGIN OVERLAY
   ============================================================================== */
.pos-login-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(8px);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.pos-login-card {
    background: var(--pos-surface);
    border: 1px solid var(--pos-border);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

.pos-login-header {
    background: linear-gradient(135deg, #1E293B, #0F172A);
    padding: 24px;
    text-align: center;
    border-bottom: 2px solid var(--primary-yellow);
}

.pos-login-body {
    padding: 24px;
}

/* ==============================================================================
   2. TOP BAR & NAVIGATION
   ============================================================================== */
.pos-topbar {
    background: var(--pos-surface);
    border-bottom: 1px solid var(--pos-border);
    padding: 10px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    position: sticky;
    top: 0;
    z-index: 50;
}

.pos-brand-group {
    display: flex;
    align-items: center;
    gap: 12px;
}

.pos-brand-badge {
    background: var(--primary-yellow);
    color: #0F172A;
    font-size: 0.72rem;
    font-weight: 900;
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.pos-brand-title {
    font-size: 1.2rem;
    font-weight: 800;
    color: #FFFFFF;
}

.pos-brand-title span {
    color: var(--primary-yellow);
}

.pos-nav-tabs {
    display: flex;
    gap: 6px;
    background: var(--pos-bg);
    padding: 4px;
    border-radius: var(--radius-md);
    border: 1px solid var(--pos-border);
    overflow-x: auto;
}

.pos-tab-btn {
    background: transparent;
    border: none;
    color: var(--pos-text-muted);
    font-weight: 700;
    font-size: 0.82rem;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    transition: all 0.2s;
}

.pos-tab-btn:hover {
    color: var(--pos-text);
    background: rgba(255, 255, 255, 0.05);
}

.pos-tab-btn.active {
    background: var(--primary-yellow);
    color: #0F172A;
    box-shadow: var(--shadow-sm);
}

.pos-topbar-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.rate-badge {
    background: rgba(16, 185, 129, 0.15);
    border: 1px solid var(--success-green);
    color: #34D399;
    font-size: 0.78rem;
    font-weight: 800;
    padding: 4px 10px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    gap: 4px;
}

/* ==============================================================================
   3. BOTONES Y CONTROLES REUTILIZABLES
   ============================================================================== */
.btn-pos {
    border: none;
    font-family: inherit;
    font-weight: 700;
    border-radius: var(--radius-sm);
    padding: 8px 14px;
    font-size: 0.85rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.15s ease;
    text-decoration: none;
}

.btn-pos-primary {
    background: var(--primary-yellow);
    color: #0F172A;
}

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

.btn-pos-dark {
    background: var(--pos-card);
    color: var(--pos-text);
    border: 1px solid var(--pos-border);
}

.btn-pos-dark:hover {
    background: var(--pos-border);
}

.btn-pos-danger {
    background: rgba(239, 68, 68, 0.2);
    color: #F87171;
    border: 1px solid #EF4444;
}

.btn-pos-danger:hover {
    background: #EF4444;
    color: #FFFFFF;
}

.btn-pos-success {
    background: var(--success-green);
    color: #FFFFFF;
}

.btn-pos-success:hover {
    background: #059669;
}

.btn-pos-blue {
    background: var(--accent-blue);
    color: #FFFFFF;
}

.btn-pos-blue:hover {
    background: #2563EB;
}

.pos-input {
    width: 100%;
    background: var(--pos-bg);
    border: 1.5px solid var(--pos-border);
    border-radius: var(--radius-sm);
    padding: 9px 12px;
    color: #FFFFFF;
    font-size: 0.88rem;
    outline: none;
    font-family: inherit;
    transition: border-color 0.2s;
}

.pos-input:focus {
    border-color: var(--primary-yellow);
}

/* ==============================================================================
   4. LAYOUT DE CAJA / MOSTRADOR (TERMINAL DE VENTA)
   ============================================================================== */
.pos-cashier-layout {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 16px;
    padding: 16px;
    flex: 1;
    min-height: calc(100vh - 70px);
}

@media (max-width: 960px) {
    .pos-cashier-layout {
        grid-template-columns: 1fr;
    }
}

.pos-catalog-panel {
    background: var(--pos-surface);
    border: 1px solid var(--pos-border);
    border-radius: var(--radius-lg);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.pos-search-bar-row {
    display: flex;
    gap: 10px;
    align-items: center;
}

.pos-cat-chips-scroll {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 4px;
}

.pos-cat-chip {
    background: var(--pos-card);
    border: 1px solid var(--pos-border);
    color: var(--pos-text-muted);
    font-size: 0.8rem;
    font-weight: 700;
    padding: 6px 14px;
    border-radius: var(--radius-full);
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
}

.pos-cat-chip:hover {
    color: #FFFFFF;
    border-color: var(--primary-yellow);
}

.pos-cat-chip.active {
    background: var(--primary-yellow);
    color: #0F172A;
    border-color: var(--primary-yellow);
}

.pos-items-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
    overflow-y: auto;
    max-height: calc(100vh - 230px);
    padding-right: 4px;
}

.pos-item-card {
    background: var(--pos-card);
    border: 1.5px solid var(--pos-border);
    border-radius: var(--radius-md);
    padding: 10px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    position: relative;
    transition: transform 0.15s, border-color 0.15s;
    user-select: none;
}

.pos-item-card:hover {
    transform: translateY(-2px);
    border-color: var(--primary-yellow);
}

.pos-item-card.out-of-stock {
    opacity: 0.5;
    filter: grayscale(0.8);
    cursor: not-allowed;
}

.pos-card-badges {
    position: absolute;
    top: 6px;
    left: 6px;
    display: flex;
    flex-direction: column;
    gap: 3px;
    z-index: 2;
}

.pos-badge-stock {
    font-size: 0.65rem;
    font-weight: 800;
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    background: rgba(16, 185, 129, 0.9);
    color: #FFFFFF;
}

.pos-badge-stock.low {
    background: #EF4444;
}

.pos-badge-discount {
    font-size: 0.68rem;
    font-weight: 900;
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    background: #E11D48;
    color: #FFFFFF;
}

.pos-item-img {
    width: 100%;
    height: 110px;
    object-fit: contain;
    background: #FFFFFF;
    border-radius: var(--radius-sm);
    padding: 6px;
    margin-bottom: 8px;
}

.pos-item-code {
    font-size: 0.7rem;
    font-family: monospace;
    color: var(--primary-yellow);
    font-weight: 700;
}

.pos-item-name {
    font-size: 0.85rem;
    font-weight: 700;
    color: #FFFFFF;
    line-height: 1.25;
    height: 34px;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    margin-bottom: 6px;
}

.pos-item-pricing {
    margin-top: auto;
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 4px;
}

.pos-price-bs {
    font-size: 1.05rem;
    font-weight: 900;
    color: #10B981;
}

.pos-price-bs.discounted {
    color: #F43F5E;
}

.pos-price-usd {
    font-size: 0.72rem;
    color: var(--pos-text-muted);
}

.pos-price-old {
    font-size: 0.75rem;
    color: var(--pos-text-dim);
    text-decoration: line-through;
}

/* ==============================================================================
   5. PANEL DERECHO: TICKET DE VENTA / CARRITO POS
   ============================================================================== */
.pos-ticket-panel {
    background: var(--pos-surface);
    border: 1px solid var(--pos-border);
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.pos-ticket-header {
    background: var(--pos-card);
    padding: 14px 16px;
    border-bottom: 1px solid var(--pos-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.pos-ticket-title {
    font-size: 1rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    gap: 8px;
}

.pos-ticket-items-list {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: calc(100vh - 460px);
    min-height: 220px;
}

.pos-ticket-row {
    background: var(--pos-card);
    border: 1px solid var(--pos-border);
    border-radius: var(--radius-sm);
    padding: 8px 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.pos-row-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
}

.pos-row-name {
    font-size: 0.82rem;
    font-weight: 700;
    color: #FFFFFF;
    line-height: 1.2;
}

.pos-row-color {
    font-size: 0.7rem;
    color: var(--primary-yellow);
    font-weight: 700;
}

.pos-row-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.pos-qty-controls {
    display: flex;
    align-items: center;
    gap: 4px;
    background: var(--pos-bg);
    border-radius: 4px;
    padding: 2px 4px;
}

.pos-qty-btn {
    width: 24px;
    height: 24px;
    background: var(--pos-border);
    border: none;
    color: #FFFFFF;
    border-radius: 4px;
    font-weight: 800;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pos-qty-btn:hover {
    background: var(--primary-yellow);
    color: #0F172A;
}

.pos-qty-number {
    font-size: 0.85rem;
    font-weight: 800;
    min-width: 26px;
    text-align: center;
}

.pos-row-subtotal {
    font-size: 0.95rem;
    font-weight: 800;
    color: #10B981;
}

.pos-ticket-totals-box {
    background: var(--pos-bg);
    border-top: 1px solid var(--pos-border);
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.pos-total-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    color: var(--pos-text-muted);
}

.pos-grand-total-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px dashed var(--pos-border);
}

.pos-grand-total-large {
    font-size: 1.6rem;
    font-weight: 900;
    color: var(--primary-yellow);
}

.pos-btn-checkout {
    background: var(--primary-yellow);
    color: #0F172A;
    border: none;
    padding: 14px;
    font-size: 1.05rem;
    font-weight: 900;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: background 0.15s;
}

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

/* ==============================================================================
   6. SECCIÓN DE REPORTES ARONIUM (KPIs, UTILIDADES Y MÁRGENES)
   ============================================================================== */
.pos-report-section {
    padding: 20px;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

.kpi-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.kpi-card {
    background: var(--pos-surface);
    border: 1px solid var(--pos-border);
    border-radius: var(--radius-lg);
    padding: 18px 20px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    box-shadow: var(--shadow-sm);
}

.kpi-title {
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--pos-text-muted);
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

.kpi-value-bs {
    font-size: 1.6rem;
    font-weight: 900;
    color: #FFFFFF;
}

.kpi-value-usd {
    font-size: 0.85rem;
    color: var(--pos-text-muted);
    font-weight: 700;
    margin-top: 2px;
}

.kpi-icon-wrap {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Tablas Modernas Dark */
.pos-table-card {
    background: var(--pos-surface);
    border: 1px solid var(--pos-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.pos-table-header-bar {
    padding: 14px 20px;
    border-bottom: 1px solid var(--pos-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.pos-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.pos-table th {
    background: var(--pos-card);
    padding: 12px 16px;
    text-align: left;
    font-weight: 800;
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--pos-text-muted);
    border-bottom: 1px solid var(--pos-border);
}

.pos-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--pos-border);
    color: var(--pos-text);
}

.pos-table tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}

/* ==============================================================================
   7. MODALES Y DIÁLOGOS
   ============================================================================== */
.pos-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(5px);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.pos-modal-overlay.active {
    display: flex;
}

.pos-modal-card {
    background: var(--pos-surface);
    border: 1px solid var(--pos-border);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 500px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.pos-modal-header {
    background: var(--pos-card);
    padding: 16px 20px;
    border-bottom: 1px solid var(--pos-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.pos-modal-body {
    padding: 20px;
    overflow-y: auto;
    max-height: 75vh;
}

.pos-modal-footer {
    background: var(--pos-card);
    padding: 14px 20px;
    border-top: 1px solid var(--pos-border);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* ==============================================================================
   8. TICKET TÉRMICO 80mm PARA IMPRESIÓN
   ============================================================================== */
@media print {
    body * {
        visibility: hidden !important;
    }
    #thermalPrintSection, #thermalPrintSection * {
        visibility: visible !important;
        display: block !important;
    }
    #thermalPrintSection {
        position: absolute !important;
        left: 0 !important;
        top: 0 !important;
        width: 80mm !important;
        background: #FFFFFF !important;
        color: #000000 !important;
        padding: 4mm !important;
        font-family: monospace !important;
    }
}
