@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
    --primary: #0066FF;
    --primary-dark: #0052CC;
    --secondary: #6B7280;
    --success: #10B981;
    --warning: #F59E0B;
    --danger: #EF4444;
    --bg-main: #F3F4F6;
    --bg-card: #FFFFFF;
    --text-main: #111827;
    --text-muted: #6B7280;
    --border-color: #E5E7EB;
    --glass: rgba(255, 255, 255, 0.7);
    --glass-border: rgba(255, 255, 255, 0.2);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --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);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

body {
    background-color: var(--bg-main);
    color: var(--text-main);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* Base Layout (MOBILE FIRST) */
.app-wrapper {
    display: block; /* Stack everything vertically */
    min-height: 100vh;
}

.sidebar {
    display: none; /* Hide sidebar on mobile */
    background: #111827;
    color: white;
    padding: 20px;
    flex-direction: column;
    box-shadow: 4px 0 10px rgba(0, 0, 0, 0.1);
}

.main-content {
    background: var(--bg-main);
    padding: 15px;
    padding-bottom: 90px; /* Space for Mobile Nav */
}

.top-header {
    display: flex !important; /* Show mobile header */
    background: white;
    padding: 15px;
    border-bottom: 1px solid var(--border-color);
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
}

/* Glassmorphism utility */
.glass {
    background: var(--glass);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
}

/* Common Components */
button { cursor: pointer; border: none; outline: none; transition: all 0.2s ease; border-radius: var(--radius-sm); padding: 10px 20px; font-weight: 500; }
button:active { transform: scale(0.98); }
.btn-primary { background-color: var(--primary); color: white; }
.btn-primary:hover { background-color: var(--primary-dark); box-shadow: 0 0 15px rgba(0, 102, 255, 0.4); }

input { width: 100%; padding: 12px 16px; border: 1px solid var(--border-color); border-radius: var(--radius-sm); font-size: 1rem; transition: border-color 0.2s, box-shadow 0.2s; background: white; }
input:focus { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(0, 102, 255, 0.1); outline: none; }

.card { background: var(--bg-card); border-radius: var(--radius-md); box-shadow: var(--shadow-md); padding: 24px; }

/* Ticket Tabs */
.ticket-tabs { display: flex; gap: 5px; margin-bottom: -1px; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.ticket-tab { padding: 12px 20px; background: #e5e7eb; border: 1px solid var(--border-color); border-bottom: none; border-radius: var(--radius-sm) var(--radius-sm) 0 0; color: var(--text-muted); font-weight: 600; cursor: pointer; display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.ticket-tab.active { background: var(--bg-card); color: var(--primary); border-top: 3px solid var(--primary); }

/* Mobile Navigation */
.mobile-nav {
    display: flex; /* Visible by default */
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #111827;
    height: 65px;
    z-index: 1000;
    justify-content: space-around;
    align-items: center;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.2);
}
.mobile-nav-link { color: #9ca3af; text-decoration: none; display: flex; flex-direction: column; align-items: center; font-size: 0.7rem; gap: 4px; }
.mobile-nav-link.active { color: var(--primary); }
.mobile-nav-link i { font-size: 1.2rem; }

/* Grid Systems (Responsive) */
.sales-grid { display: grid; grid-template-columns: 1fr; gap: 20px; }
/* Estilos de tabla POS movidos a app.html para mayor control */
.pos-table { width: 100%; border-collapse: collapse; background: white; border-radius: var(--radius-md); overflow: hidden; }

/* DESKTOP OVERRIDES (min-width: 1024px) */
@media (min-width: 1024px) {
    .app-wrapper {
        display: grid;
        grid-template-columns: 260px 1fr;
    }

    .sidebar {
        display: flex;
    }

    .mobile-nav {
        display: none;
    }

    .top-header {
        display: none !important;
    }

    .main-content {
        padding: 30px;
    }

    .sales-grid {
        grid-template-columns: 1fr 350px;
    }

    /* Standard Table View */
    .pos-table thead { display: table-header-group; }
    .pos-table { display: table; }
    .pos-table tbody { display: table-row-group; }
    .pos-table tr { display: table-row; border: none; }
    .pos-table td { display: table-cell; text-align: left; padding: 16px; border-bottom: 1px solid var(--border-color); }
    .pos-table td::before { display: none; }
    
    .pos-table th { text-align: left; padding: 16px; background: #f9fafb; color: var(--text-muted); border-bottom: 1px solid var(--border-color); font-weight: 600; }
}

/* Animations */
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.animate-fade-in { animation: fadeIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards; }

/* Utils */
.f-key { padding: 2px 6px; background: #e5e7eb; color: #4b5563; border-radius: 4px; font-size: 0.75rem; font-weight: 700; margin-left: 8px; border: 1px solid #d1d5db; }
.sidebar-header { padding: 10px 0 40px; font-size: 1.5rem; font-weight: 800; border-bottom: 1px solid #1f2937; margin-bottom: 30px; }
.nav-link { display: flex; align-items: center; padding: 14px 16px; color: #9ca3af; text-decoration: none; border-radius: var(--radius-sm); margin-bottom: 4px; transition: all 0.2s; font-weight: 500; }
.nav-link:hover { background: #1f2937; color: white; }
.nav-link.active { background: var(--primary); color: white; box-shadow: 0 4px 12px rgba(0, 102, 255, 0.25); }
.nav-link i { width: 24px; margin-right: 12px; font-size: 1.1rem; }

/* 📦 PRODUCT CATALOG GRID SYSTEM */
.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 25px;
    padding-top: 10px;
}

.product-card {
    background: white;
    border-radius: 20px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    border: 1px solid #f1f5f9;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.product-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    border-color: var(--primary);
}

.product-image-container {
    width: 100%;
    height: 180px;
    position: relative;
    background: #f8fafc;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.product-image-container img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 10px;
}

.product-badge {
    position: absolute;
    top: 12px;
    left: 12px;
    padding: 4px 10px;
    border-radius: 8px;
    font-size: 0.7rem;
    font-weight: 800;
    text-transform: uppercase;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(4px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.product-info {
    padding: 20px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.product-price-tag {
    font-size: 1.5rem;
    font-weight: 900;
    color: var(--primary);
}

.product-actions {
    position: absolute;
    top: 12px;
    right: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    opacity: 0;
    transform: translateX(10px);
    transition: all 0.3s ease;
}

.product-card:hover .product-actions {
    opacity: 1;
    transform: translateX(0);
}

.btn-icon {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    background: white;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    transition: all 0.2s;
}

.btn-edit { color: var(--primary); }
.btn-edit:hover { background: var(--primary); color: white; }
.btn-delete { color: var(--danger); }
.btn-delete:hover { background: var(--danger); color: white; }

/* TABLET ADJUSTMENTS */
@media (max-width: 1024px) {
    .product-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
        gap: 15px;
    }
}

/* MOBILE ADJUSTMENTS */
@media (max-width: 600px) {
    .product-grid {
        grid-template-columns: 1fr;
    }
}
/* 🍞 TOAST NOTIFICATIONS (Premium) */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 12px;
    pointer-events: none; /* Let clicks pass through if not on a toast */
}

.toast {
    pointer-events: auto;
    min-width: 300px;
    max-width: 450px;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-left: 5px solid var(--primary);
    border-radius: var(--radius-md);
    padding: 16px 20px;
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.12);
    display: flex;
    align-items: center;
    gap: 15px;
    color: var(--text-main);
    font-weight: 500;
    animation: toastIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
    transition: all 0.3s ease;
    opacity: 0;
}

.toast.removing {
    transform: translateX(50px);
    opacity: 0;
}

.toast i {
    font-size: 1.4rem;
}

.toast-success { border-left-color: var(--success); }
.toast-success i { color: var(--success); }

.toast-error { border-left-color: var(--danger); }
.toast-error i { color: var(--danger); }

.toast-warning { border-left-color: var(--warning); }
.toast-warning i { color: var(--warning); }

.toast-info { border-left-color: var(--primary); }
.toast-info i { color: var(--primary); }

@keyframes toastIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* Responsive adjustment for mobile */
@media (max-width: 600px) {
    .toast-container {
        top: 10px;
        right: 10px;
        left: 10px;
    }
    .toast {
        min-width: 100%;
        font-size: 0.9rem;
    }
}

/* 🔍 REAL-TIME PRODUCT SEARCH RESULTS */
.pos-search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
    z-index: 3500;
    max-height: 400px;
    overflow-y: auto;
    display: none;
    margin-top: 2px;
}

.search-result-item {
    display: flex;
    align-items: center;
    padding: 18px 20px; /* Incrementado para facilitar toque en móviles */
    gap: 15px;
    cursor: pointer;
    transition: all 0.2s ease;
    border-bottom: 1px solid rgba(0, 0, 0, 0.03);
    color: var(--text-main);
}

.search-result-item:last-child { border-bottom: none; }

.search-result-item:hover, .search-result-item.selected,
.customer-result-item:hover, .customer-result-item.selected {
    background: var(--primary);
    color: white !important;
}

.search-result-item:hover .text-muted, .search-result-item.selected .text-muted,
.customer-result-item:hover .text-muted, .customer-result-item.selected .text-muted,
.search-result-item:hover .balance-amount, .search-result-item.selected .balance-amount,
.customer-result-item:hover .balance-amount, .customer-result-item.selected .balance-amount {
    color: rgba(255, 255, 255, 0.9) !important;
}

/* 💎 PREMIUM CONFIRMATION MODAL */
.modal-confirm {
    max-width: 450px !important;
    text-align: center;
    border-radius: 28px !important;
    border: 1px solid rgba(255, 255, 255, 0.4) !important;
    background: rgba(255, 255, 255, 0.8) !important;
    backdrop-filter: blur(20px) saturate(180%) !important;
    -webkit-backdrop-filter: blur(20px) saturate(180%) !important;
}

.modal-confirm i {
    font-size: 3.5rem;
    margin-bottom: 20px;
    display: block;
}

.confirm-title {
    font-size: 1.5rem;
    font-weight: 800;
    margin-bottom: 10px;
    color: var(--text-main);
}

.confirm-message {
    color: var(--text-muted);
    line-height: 1.6;
    margin-bottom: 25px;
}

.confirm-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.confirm-actions .btn-confirm {
    flex: 1;
    height: 55px;
    border-radius: 16px;
    font-weight: 700;
    font-size: 1rem;
}

.btn-cancel {
    background: #f1f5f9;
    color: #64748b;
}

.btn-danger-confirm {
    background: #ef4444;
    color: white;
}

@keyframes popIn {
    0% { transform: scale(0.85); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

.animate-pop-in {
    animation: popIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.search-img {
    width: 45px;
    height: 45px;
    border-radius: 8px;
    object-fit: contain;
    background: #f8fafc;
    border: 1px solid #eee;
}

.search-info { flex: 1; min-width: 0; }
.search-name { font-weight: 700; font-size: 1rem; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-meta { font-size: 0.8rem; display: flex; gap: 10px; }

.search-price { font-weight: 800; color: var(--primary); font-size: 1.1rem; }
.search-result-item:hover .search-price, .search-result-item.selected .search-price { color: white; }

.search-stock-badge { padding: 2px 6px; border-radius: 4px; font-weight: 700; font-size: 0.7rem; text-transform: uppercase; }
.stock-ok { background: #dcfce7; color: #166534; }
.stock-low { background: #fef9c3; color: #854d0e; }
.stock-out { background: #fee2e2; color: #991b1b; }
/* 💎 REPORTS STYLES */
.btn-filter {
    padding: 8px 16px;
    border-radius: 10px;
    background: #f1f5f9;
    color: #475569;
    border: 1px solid #e2e8f0;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-filter:hover {
    background: #e2e8f0;
    color: var(--primary);
}

.btn-filter.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    box-shadow: 0 4px 10px rgba(59, 130, 246, 0.3);
}

.animate-fade-in {
    animation: fadeIn 0.4s ease forwards;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.badge {
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 700;
}

.badge-success { background: #d1fae5; color: #065f46; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger { background: #fee2e2; color: #991b1b; }
