/**
 * Sistema Sufarma - Estilos Principales
 * Diseño moderno basado en referencia del usuario
 */

/* ===== Variables CSS - Refactoring UI Design System ===== */
:root {
    /* Teal Primary Palette */
    --teal-50: #e0f7f4;
    --teal-100: #99e6db;
    --teal-200: #66d9c9;
    --teal-300: #33ccb7;
    --teal-400: #00bfa5;
    --teal-500: #00a88f;
    --teal-600: #008f7a;
    --teal-700: #007665;
    --teal-800: #005d50;

    /* Green Success Palette */
    --green-50: #d1fae5;
    --green-100: #a7f3d0;
    --green-200: #6ee7b7;
    --green-300: #34d399;
    --green-400: #22c55e;
    --green-500: #16a34a;
    --green-600: #15803d;
    --green-700: #166534;

    /* Amber Warning Palette */
    --amber-50: #fef3c7;
    --amber-100: #fde68a;
    --amber-200: #fcd34d;
    --amber-300: #fbbf24;
    --amber-400: #f59e0b;
    --amber-500: #d97706;
    --amber-600: #b45309;

    /* Red Danger Palette */
    --red-50: #fee2e2;
    --red-100: #fecaca;
    --red-200: #fca5a5;
    --red-300: #f87171;
    --red-400: #ef4444;
    --red-500: #dc2626;
    --red-600: #b91c1c;

    /* Gray Neutral Palette */
    --gray-50: #f8fafc;
    --gray-100: #f1f5f9;
    --gray-200: #e2e8f0;
    --gray-300: #cbd5e1;
    --gray-400: #94a3b8;
    --gray-500: #64748b;
    --gray-600: #475569;
    --gray-700: #334155;
    --gray-800: #1e293b;
    --gray-900: #0f172a;

    /* Semantic Colors */
    --primary-color: var(--teal-400);
    --primary-dark: var(--teal-600);
    --primary-light: var(--teal-100);
    --success-color: var(--green-400);
    --success-dark: var(--green-600);
    --warning-color: var(--amber-400);
    --danger-color: var(--red-500);

    /* Background & Surface */
    --background: var(--gray-50);
    --card-bg: #ffffff;
    --surface-elevated: #ffffff;

    /* Text Colors */
    --text-primary: var(--gray-900);
    --text-secondary: var(--gray-500);
    --text-tertiary: var(--gray-400);

    /* Border Colors */
    --border-color: var(--gray-200);
    --border-light: var(--gray-100);
    --border-dark: var(--gray-300);

    /* Shadow System - Layered for Depth */
    --shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.1),
        0 1px 2px 0 rgba(0, 0, 0, 0.06);
    --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);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1),
        0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --shadow-2xl: 0 25px 50px -12px rgba(0, 0, 0, 0.25);

    /* Border Radius */
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;

    /* Spacing Scale */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-6: 1.5rem;
    --space-8: 2rem;
}

/* ===== Reset & Base ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
}

/* ===== Header ===== */
.header {
    background: linear-gradient(135deg, var(--teal-600) 0%, var(--teal-700) 100%);
    padding: 1rem 2rem;
    box-shadow: var(--shadow-md);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-container {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: white;
}

.logo-icon {
    font-size: 2rem;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

/* Sales Summary */
.sales-summary {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    color: white;
    font-size: 0.85rem;
    margin-left: var(--space-6);
}

.sales-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
    align-items: center;
}

.sales-label {
    font-size: 0.7rem;
    opacity: 0.85;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.sales-amount {
    font-size: 0.95rem;
    font-weight: 700;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.sales-total {
    font-size: 1.1rem;
    color: var(--amber-200);
}

.sales-divider {
    opacity: 0.3;
    font-size: 1.2rem;
    font-weight: 300;
}

.nav-menu {
    display: flex;
    gap: 1.5rem;
    list-style: none;
}

.nav-link {
    color: rgba(255, 255, 255, 0.9);
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-md);
    transition: all 0.2s;
    font-weight: 500;
}

.nav-link:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.nav-link.active {
    background: rgba(255, 255, 255, 0.15);
    color: white;
    box-shadow: var(--shadow-xs);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 1rem;
    background-color: var(--background);
    border-radius: var(--radius-md);
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
}

.btn-logout {
    padding: 0.5rem 1rem;
    background-color: var(--secondary-color);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s;
}

.btn-logout:hover {
    background-color: var(--secondary-light);
}

/* ===== Main Layout ===== */
.main-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1.5rem;
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 1.5rem;
}

/* ===== Search Bar ===== */
.search-section {
    margin-bottom: 1.5rem;
}

.search-bar {
    position: relative;
}

.search-input {
    width: 100%;
    padding: 0.875rem 1rem 0.875rem 3rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-lg);
    font-size: 1rem;
    transition: all 0.2s;
}

.search-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.1);
}

.search-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    font-size: 1.25rem;
}

/* ===== Product Grid ===== */
.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1rem;
}

/* Product Card */
.product-card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid var(--border-light);
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
}

.product-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--border-color);
}

/* Stock Indicator */
.stock-indicator {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    padding: var(--space-2) var(--space-3);
    background: var(--gray-100);
    gap: var(--space-2);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-primary);
}

.stock-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--danger-color);
    box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.1);
}

.stock-dot.in-stock {
    background: var(--success-color);
    box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.1);
}

.stock-dot.low-stock {
    background: var(--warning-color);
    box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.1);
}

/* Product Image Section with Hover Overlay */
.product-image-section {
    background: white;
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 170px;
    position: relative;
}

.product-image {
    width: 130px;
    height: 130px;
    object-fit: contain;
}

/* Branch Stock Overlay - Hidden by default */
.branch-stock-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.98);
    display: none;
    grid-template-columns: repeat(4, 1fr);
    gap: 0;
    padding: 4px;
    align-items: center;
}

/* Show overlay on hover */
.product-image-section:hover .branch-stock-overlay {
    display: grid;
}

/* Branch stock items in overlay */
.branch-stock-overlay .branch-stock-item {
    padding: 4px 2px;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 2px;
    border-right: 1px solid #e0e0e0;
}

.branch-stock-overlay .branch-stock-item:last-child {
    border-right: none;
}

.branch-stock-overlay .branch-name {
    font-size: 0.6rem;
    font-weight: 600;
    color: #64748b;
    text-transform: capitalize;
}

.branch-stock-overlay .branch-stock {
    font-size: 0.65rem;
    font-weight: 700;
}

.branch-stock-overlay .branch-stock.in-stock {
    color: #22c55e;
}

.branch-stock-overlay .branch-stock.out-stock {
    color: #dc2626;
}

.branch-stock-overlay .branch-stock.loading {
    color: #94a3b8;
    font-size: 0.55rem;
}

/* Brand Label */
.brand-label {
    background: linear-gradient(135deg, var(--teal-500) 0%, var(--teal-600) 100%);
    color: white;
    padding: var(--space-2) var(--space-3);
    text-align: center;
    font-weight: 700;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.1);
}

/* Product Info */
.product-info {
    padding: 10px 12px;
    background: white;
}

.product-name {
    font-size: 0.85rem;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 2px;
    line-height: 1.2;
}

.product-codes {
    font-size: 0.7rem;
    color: #64748b;
}

/* Facturado Toggle */
.facturado-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 12px;
    background: white;
    border-top: 1px solid #e0e0e0;
    border-bottom: 1px solid #e0e0e0;
}

.facturado-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: #1e293b;
}

.toggle-buttons {
    display: flex;
    gap: 4px;
}

.toggle-btn {
    padding: 2px 10px;
    border: 1px solid #cbd5e1;
    background: white;
    border-radius: 3px;
    font-size: 0.7rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.toggle-btn.active {
    background: #22c55e;
    color: white;
    border-color: #22c55e;
}

/* Price Sections - 2 Column Grid */
.price-sections {
    padding: var(--space-2);
    background: var(--gray-50);
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-2);
}

.price-row {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-2) var(--space-1);
    background: white;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    gap: var(--space-1);
    min-height: 45px;
    box-shadow: var(--shadow-xs);
}

.price-row:hover {
    background: var(--teal-50);
    border-color: var(--teal-300);
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}

.price-row:active {
    transform: translateY(0);
    box-shadow: var(--shadow-xs);
}

/* Green styling for CAJA button */
.price-row.price-caja {
    background: linear-gradient(135deg, var(--green-400) 0%, var(--green-500) 100%);
    border-color: var(--green-500);
    box-shadow: var(--shadow-sm);
}

.price-row.price-caja:hover {
    background: linear-gradient(135deg, var(--green-500) 0%, var(--green-600) 100%);
    border-color: var(--green-600);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.price-row.price-caja .price-label,
.price-row.price-caja .price-value {
    color: white;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.price-label {
    font-size: 0.65rem;
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
    text-align: center;
}

.price-value {
    font-size: 0.8rem;
    font-weight: 700;
    color: #1e293b;
    text-align: center;
}



/* ===== Cart Sidebar ===== */
.cart-sidebar {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-md);
    position: sticky;
    top: 90px;
    max-height: calc(100vh - 110px);
    overflow-y: auto;
}

.cart-header {
    margin-bottom: 1.25rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--border-color);
}

.cart-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--secondary-color);
}

.cart-items {
    margin-bottom: 1.25rem;
}

.cart-item {
    padding: 1rem;
    background-color: var(--background);
    border-radius: var(--radius-md);
    margin-bottom: 0.75rem;
}

.cart-item-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    margin-bottom: 0.5rem;
}

.cart-item-name {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
}

.cart-item-remove {
    background: none;
    border: none;
    color: #dc2626;
    cursor: pointer;
    font-size: 1.125rem;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s;
}

.cart-item-remove:hover {
    background-color: #fee2e2;
}

.cart-item-details {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.cart-item-quantity {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.qty-btn {
    width: 28px;
    height: 28px;
    border: 1px solid var(--border-color);
    background: white;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.qty-btn:hover {
    background-color: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.qty-input {
    width: 50px;
    text-align: center;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 0.25rem;
}

.cart-item-total {
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--primary-color);
}

.cart-totals {
    padding: 1rem 0;
    border-top: 2px solid var(--border-color);
    margin-bottom: 1rem;
}

.total-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
}

.total-row.grand-total {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--secondary-color);
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 2px solid var(--border-color);
}

.btn-primary {
    width: 100%;
    padding: 1rem;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: var(--shadow-md);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    width: 100%;
    padding: 0.875rem;
    background: white;
    color: var(--secondary-color);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    margin-top: 0.75rem;
}

.btn-secondary:hover {
    border-color: var(--secondary-color);
    background-color: var(--background);
}

/* ===== Empty States ===== */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-secondary);
}

.empty-state-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-state-text {
    font-size: 1rem;
}

/* ===== Loading States ===== */
.loading {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2rem;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ===== Responsive ===== */
@media (max-width: 1024px) {
    .main-container {
        grid-template-columns: 1fr;
    }

    .cart-sidebar {
        position: relative;
        top: 0;
        max-height: none;
    }
}

@media (max-width: 768px) {
    .header-container {
        flex-direction: column;
        gap: 1rem;
    }

    .nav-menu {
        flex-wrap: wrap;
        justify-content: center;
    }

    .products-grid {
        grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    }
}

@media (max-width: 480px) {
    .products-grid {
        grid-template-columns: 1fr;
    }

    .price-buttons {
        grid-template-columns: 1fr;
    }
}


/**
 * Sistema Sufarma - Estilos Principales
 * Diseño moderno basado en referencia del usuario
 */

/* ... (MANTÉN TODO EL CÓDIGO CSS ANTERIOR AQUÍ) ... */

/* ===== AGREGAR AL FINAL DEL ARCHIVO ===== */

/* Modal Styles (Respaldo) */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 9999;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background-color: white;
    padding: 0;
    border-radius: 12px;
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
}

.modal-header {
    padding: 15px 20px;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    font-size: 1.25rem;
    color: var(--secondary-color);
    margin: 0;
}

.modal-body {
    padding: 20px;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #64748b;
    transition: color 0.2s;
}

.modal-close:hover {
    color: #ef4444;
}
/* ===== User Selection Modal Styles ===== */
.user-error-message {
    display: none;
    padding: 0.75rem 1rem;
    background-color: var(--red-50);
    border: 1px solid var(--red-200);
    border-radius: var(--radius-md);
    color: var(--red-600);
    font-size: 0.875rem;
    margin-bottom: 1rem;
    font-weight: 500;
}

.user-error-message.show {
    display: block;
}

.user-modal-form {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.user-form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.user-form-label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
}

.user-form-select,
.user-form-input {
    padding: 0.75rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    transition: all 0.2s;
    font-family: ''Inter'', sans-serif;
}

.user-form-select:focus,
.user-form-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0, 191, 165, 0.1);
}

.user-form-hint {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-style: italic;
}

.user-modal-buttons {
    display: flex;
    gap: 0.75rem;
    margin-top: 0.5rem;
}

.btn-cancel,
.btn-confirm {
    flex: 1;
    padding: 0.875rem 1.5rem;
    border: none;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: ''Inter'', sans-serif;
}

.btn-cancel {
    background-color: var(--gray-100);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-cancel:hover {
    background-color: var(--gray-200);
}

.btn-confirm {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
    box-shadow: var(--shadow-sm);
}

.btn-confirm:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-confirm:active {
    transform: translateY(0);
}
