@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Outfit:wght@600;700;800&display=swap');

:root {
    --primary-color: #6366f1;
    /* Indigo vibrant */
    --primary-hover: #4f46e5;
    --secondary-color: #f43f5e;
    /* Rose */
    --background-color: #0f172a;
    /* Slate dark */
    --card-bg: rgba(255, 255, 255, 0.95);
    --glass-bg: rgba(255, 255, 255, 0.8);
    --glass-border: rgba(255, 255, 255, 0.2);
    --text-color: #1e293b;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --danger: #ef4444;
    --success: #10b981;
    --radius: 12px;
    --shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', sans-serif;
    color: var(--text-color);
    line-height: 1.6;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    background: var(--background-color);
}

h1,
h2,
h3,
.logo {
    font-family: 'Outfit', sans-serif;
    letter-spacing: -0.02em;
}

/* Container */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 1.5rem;
    width: 100%;
}

/* Header & Navbar */
header {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--glass-border);
    padding: 1rem 0;
    position: sticky;
    top: 0;
    z-index: 1000;
}

.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-size: 1.75rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    text-decoration: none;
    transition: transform 0.3s ease;
}

.logo:hover {
    transform: scale(1.05);
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.nav-link {
    color: var(--text-color);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.95rem;
    transition: color 0.2s;
}

.nav-link:hover {
    color: var(--primary-color);
}

.logout-btn {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.2);
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.logout-btn:hover {
    background: var(--danger);
    color: white;
}

/* Auth / Login Styles */
.auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: calc(100vh - 80px);
    padding: 2rem;
}

.auth-card {
    background: var(--card-bg);
    padding: 2.5rem;
    border-radius: 20px;
    width: 100%;
    max-width: 450px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    animation: slideUp 0.5s ease-out;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.auth-card h2 {
    margin-bottom: 2rem;
    font-size: 2rem;
    text-align: center;
    color: var(--text-color);
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.form-group input {
    width: 100%;
    padding: 0.8rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 1rem;
}

.error-msg {
    background: #fee2e2;
    color: #991b1b;
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
    border: 1px solid #fecaca;
    display: none;
    text-align: center;
    font-weight: 500;
}

.btn {
    display: block;
    width: 100%;
    padding: 1rem;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-hover));
    color: white;
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 10px 15px -3px rgba(99, 102, 241, 0.3);
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 20px 25px -5px rgba(99, 102, 241, 0.4);
}

/* Filters Area */
.filters-wrapper {
    background: var(--glass-bg);
    backdrop-filter: blur(8px);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-top: 2rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--glass-border);
}

.form-control {
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 0.95rem;
    transition: all 0.2s;
    outline: none;
}

.form-control:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

/* Products Grid */
.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1.5rem;
    padding: 2rem 0;
}

.featured-grid {
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    padding: 1rem 0;
    gap: 1rem;
}

.product-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid transparent;
    display: flex;
    flex-direction: column;
}

.product-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    border-color: var(--primary-color);
}

/* Featured smaller cards */
.product-card.featured {
    font-size: 0.8rem;
}

.product-card.featured .product-info {
    padding: 0.5rem;
    gap: 0.25rem;
}

.product-card.featured .product-title {
    font-size: 0.85rem;
    margin: 0.1rem 0;
    height: auto;
    min-height: 2.2rem;
    max-height: 3.3rem;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.1rem;
}

.product-card.featured .product-price {
    font-size: 1rem;
    margin-bottom: 0.25rem;
}

.product-card.featured .stock-badge {
    font-size: 0.65rem;
    padding: 2px 4px;
}

.product-card.featured .qty-controls {
    margin-bottom: 0.4rem;
    gap: 0.25rem;
}

.product-card.featured .qty-input {
    width: 40px;
    height: 24px;
    font-size: 0.8rem;
}

.product-card.featured .qty-btn {
    width: 24px;
    height: 24px;
    font-size: 0.9rem;
}

.product-card.featured .btn-add {
    padding: 0.4rem;
    font-size: 0.8rem;
    border-radius: 4px;
}

.product-image-container {
    aspect-ratio: 1/1;
    overflow: hidden;
    background: #f1f5f9;
}

.product-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s;
}

.product-card:hover .product-image {
    transform: scale(1.1);
}

.product-actions {
    margin-top: auto;
}

.qty-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.qty-btn {
    width: 32px;
    height: 32px;
    border: 1px solid var(--border-color);
    background: white;
    border-radius: var(--radius);
    font-weight: bold;
    color: var(--primary-color);
    cursor: pointer;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.qty-btn:hover {
    background: var(--primary-color);
    color: white;
}

.qty-input {
    width: 60px;
    height: 32px;
    text-align: center;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    font-weight: 600;
}

/* Remove default number arrows if we use custom buttons,
   but user asked for arrows too. We keep them or rely on buttons?
   Better keep both for accessibility/flexibility, but usually
   they look ugly with custom buttons.
   Let's keep standard behavior for now, maybe hide them if buttons suffice.
   User explicitly asked for arrows: "con las dos flechitas...".
   So I will NOT hide them. */

.no-image {
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #e2e8f0;
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 500;
    text-align: center;
    height: 100%;
    width: 100%;
}

.product-info {
    padding: 1.25rem;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.product-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: var(--text-color);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.product-price {
    font-size: 1.35rem;
    font-weight: 800;
    color: var(--primary-color);
    margin-top: auto;
    margin-bottom: 1rem;
}

.btn-add {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 0.75rem;
    border-radius: var(--radius);
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    width: 100%;
}

.btn-add:hover {
    background: var(--primary-hover);
    transform: scale(1.02);
}

/* Lightbox */
.lightbox {
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    display: none;
    justify-content: center;
    align-items: center;
}

.lightbox-content {
    margin: auto;
    display: block;
    max-width: 90%;
    max-height: 90vh;
    animation: zoom 0.3s;
    cursor: pointer;
    transition: transform 0.2s;
}

.lightbox-content:hover {
    transform: scale(1.02);
}

@keyframes zoom {
    from {
        transform: scale(0.8);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

.lightbox-close {
    position: absolute;
    top: 25px;
    right: 35px;
    color: #f1f1f1;
    font-size: 40px;
    font-weight: bold;
    cursor: pointer;
    z-index: 2001;
}

/* Evitar que los textos de oferta bloqueen el clic en la imagen */
.offer-badge,
.offer-text-overlay {
    pointer-events: none;
}

/* Floating Cart */
.cart-float {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-hover));
    color: white;
    width: 65px;
    height: 65px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 10px 25px rgba(99, 102, 241, 0.4);
    cursor: pointer;
    z-index: 1000;
    transition: all 0.3s;
}

.cart-float:hover {
    transform: scale(1.1) rotate(-5deg);
}

.cart-count {
    position: absolute;
    top: -2px;
    right: -2px;
    background: var(--secondary-color);
    color: white;
    font-size: 0.75rem;
    min-width: 24px;
    height: 24px;
    border-radius: 12px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: 800;
    border: 2px solid white;
}

/* Sidebar Cart */
/* Sidebar Cart (Drawer Effect) */
#cartModal {
    position: fixed;
    top: 0;
    right: -550px;
    /* Start off-screen */
    width: 100%;
    max-width: 500px;
    height: 100vh;
    background: white;
    box-shadow: -5px 0 25px rgba(0, 0, 0, 0.15);
    z-index: 2000;
    padding: 2rem;
    overflow-y: auto;
    transition: right 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    display: block !important;
    /* Always display block, control visibility with right position */
    display: flex !important;
    flex-direction: column;
}

.cart-item-row {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #eee;
}

.cart-item-img {
    width: 70px;
    height: 70px;
    object-fit: cover;
    border-radius: 8px;
    background: #f1f5f9;
}

.cart-item-details {
    flex-grow: 1;
}

.btn-clear-cart {
    background: #fee2e2;
    color: #ef4444;
    border: 1px solid #fecaca;
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.85rem;
}

.btn-clear-cart:hover {
    background: #fecaca;
}

#cartModal.open {
    right: 0;
}

/* Overlay back-drop for cart */
#cartOverlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    z-index: 1999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

#cartOverlay.visible {
    opacity: 1;
    pointer-events: auto;
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 3000;
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    align-items: center;
    pointer-events: none;
}

/* Table View Styles */
.products-table-container {
    width: 100%;
    overflow-x: auto;
    background: var(--glass-bg);
    backdrop-filter: blur(8px);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    margin: 1rem 0 3rem 0;
    border: 1px solid var(--glass-border);
    width: 100%;
}

.products-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
    color: var(--text-color);
}

.products-table th,
.products-table td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.products-table th {
    background: rgba(255, 255, 255, 0.1);
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    font-size: 0.75rem;
    border-bottom: 2px solid var(--primary-color);
}

.products-table .table-img {
    width: 50px;
    height: 50px;
    object-fit: cover;
    border-radius: 4px;
    cursor: pointer;
}

.products-table .table-qty {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.products-table .qty-input {
    width: 45px;
    height: 28px;
    font-size: 0.85rem;
}

.products-table .qty-btn {
    width: 24px;
    height: 24px;
    font-size: 0.9rem;
}

.products-table .btn-add {
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
    width: auto;
}

@media (max-width: 768px) {

    .products-table th:nth-child(2),
    .products-table td:nth-child(2),
    .products-table th:nth-child(3),
    .products-table td:nth-child(3) {
        display: none;
        /* Hide Rubro/Subrubro on small screens */
    }
}



.toast {
    background: var(--card-bg);
    color: var(--text-color);
    padding: 0.8rem 1.5rem;
    border-radius: 50px;
    box-shadow: 0 10px 30px -5px rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(12px);
    display: flex;
    align-items: center;
    gap: 0.8rem;
    animation: toastIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
    opacity: 0;
    transform: translateY(20px);
    font-weight: 500;
    font-size: 0.95rem;
}

.toast.success {
    border-left: 4px solid var(--success);
}

.toast.error {
    border-left: 4px solid var(--danger);
}

.toast.info {
    border-left: 4px solid var(--primary-color);
}

@keyframes toastIn {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes toastOut {
    to {
        opacity: 0;
        transform: translateY(-20px);
    }
}

/* Order Cards (Mis Pedidos) */
.order-card {
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    border: 1px solid var(--glass-border);
    transition: all 0.3s;
}

.order-card:hover {
    transform: scale(1.01);
    background: white;
}

/* Background */
#bg-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    filter: blur(3px) brightness(0.4) saturate(1.2);
    transform: scale(1.05);
    /* Evitar bordes blancos por blur */
    transition: background-image 1.5s ease-in-out;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 10px;
}

::-webkit-scrollbar-track {
    background: #f1f5f9;
}

::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary-hover);
}

/* Badges */
.offer-badge {
    background: var(--secondary-color) !important;
    text-transform: uppercase;
    font-size: 0.7rem !important;
    padding: 4px 10px !important;
}

/* Stock Badges */
.stock-badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
}

.stock-badge.success {
    background-color: #dcfce7;
    color: #166534;
}

.stock-badge.warning {
    background-color: #fef9c3;
    color: #854d0e;
}

.stock-badge.danger {
    background-color: #fee2e2;
    color: #991b1b;
}