* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Poppins', sans-serif;
    background: #f5f5f5;
}

.tienda-header {
    background: linear-gradient(135deg, #004aad 0%, #001f4d 100%);
    color: white;
    padding: 15px 0;
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.header-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo h2 {
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: white;
    text-decoration: none !important;
}

.user-actions {
    display: contents;
    align-items: center;
    gap: 20px;
}

.user-info {
    display: flex;
    align-items: center;
    font-size: small;
    gap: 10px;
}

.user-info i {
    font-size: 24px;
}

.cart-icon {
    position: relative;
    cursor: pointer;
    font-size: 24px;
}

.cart-count {
    position: absolute;
    top: -10px;
    right: -10px;
    background: #ff6b6b;
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
}

.logout-btn {
    color: white;
    text-decoration: none;
    
    border: 1px solid white;
    border-radius: 5px;
    transition: all 0.3s;
}

.logout-btn:hover {
    background: white;
    color: #004aad;
}

.tienda-container {
    max-width: 1400px;
    margin: 20px auto;
    padding: 0 20px;
    display: grid;
    grid-template-columns: 220px 850px 330px;
    gap: 20px;
}

/* Sidebar de categorías */
.categorias-sidebar {
    background: white;
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    height: fit-content;
    position: sticky;
    top: 100px;
}

.categorias-sidebar h3 {
    margin-bottom: 15px;
    color: #333;
    display: flex;
    align-items: center;
    gap: 10px;
}

.categoria-item {
    padding: 12px 15px;
    margin-bottom: 5px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.categoria-item:hover {
    background: #f0f7ff;
}

.categoria-item.active {
    background: #004aad;
    color: white;
}

.categoria-item .count {
    background: #e1e1e1;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
}

.categoria-item.active .count {
    background: rgba(255,255,255,0.3);
}

/* Grid de productos */
.productos-grid { 
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 20px;
    margin-left: 50px;
    align-items: start;
}

.producto-card {
      background: #fff;
    padding: 15px;
    border-radius: 10px;
    height: auto; /* importante */
    min-height: 200px; /* opcional */
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    overflow: hidden;
}

.producto-card h3 {
    font-size: 16px;
    word-wrap: break-word;
    white-space: normal;
}

.producto-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 20px rgba(0,0,0,0.15);
}

.producto-imagen {
    width: 100%;
    height: 180px;
    object-fit: cover;
    background: #f0f0f0;
}

.producto-info {
    padding: 15px;
}

.producto-nombre {
    font-weight: 600;
    margin-bottom: 5px;
    color: #333;
}

.producto-descripcion {
    font-size: 12px;
    color: #666;
    margin-bottom: 10px;
    min-height: 36px;
}

.producto-precio {
    font-size: 20px;
    font-weight: bold;
    color: #004aad;
    margin-bottom: 10px;
}

.btn-agregar {
    width: 100%;
    padding: 10px;
    background: #004aad;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-weight: 500;
    transition: background 0.3s;
}

.btn-agregar:hover {
    background: #003a8a;
}

/* Carrito sidebar */
.carrito-sidebar {
    background: white;
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    height: fit-content;
    position: sticky;
    top: 100px;
}

.carrito-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid #f0f0f0;
}

.carrito-header h3 {
    display: flex;
    align-items: center;
    gap: 10px;
}

.carrito-items {
    max-height: 400px;
    overflow-y: auto;
    margin-bottom: 20px;
}

.carrito-item {
    display: flex;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid #f0f0f0;
}

.carrito-item-img {
    width: 50px;
    height: 50px;
    object-fit: cover;
    border-radius: 5px;
}

.carrito-item-info {
    flex: 1;
}

.carrito-item-nombre {
    font-weight: 500;
    font-size: 14px;
    margin-bottom: 5px;
}

.carrito-item-precio {
    color: #004aad;
    font-weight: 600;
    font-size: 14px;
}

.carrito-item-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 5px;
}

.cantidad-control {
    display: flex;
    align-items: center;
    gap: 5px;
}

.cantidad-btn {
    width: 25px;
    height: 25px;
    border: 1px solid #ddd;
    background: white;
    border-radius: 3px;
    cursor: pointer;
    font-weight: bold;
}

.cantidad-btn:hover {
    background: #f0f0f0;
}

.cantidad-num {
    min-width: 30px;
    text-align: center;
    font-weight: 500;
}

.btn-eliminar {
    color: #ff6b6b;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 16px;
}

.btn-eliminar:hover {
    color: #ff3838;
}

.carrito-total {
    padding: 15px 0;
    border-top: 2px solid #f0f0f0;
}

.total-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
    font-size: 16px;
}

.total-final {
    font-size: 20px;
    font-weight: bold;
    color: #004aad;
}

.codigo-referido-section {
    margin: 15px 0;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
}

.codigo-referido-section label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #333;
}

.codigo-input {
    display: flex;
    gap: 10px;
}

.codigo-input input {
    flex: 1;
    padding: 10px;
    border: 2px solid #e1e1e1;
    border-radius: 5px;
    font-size: 14px;
}

.codigo-input input:focus {
    border-color: #004aad;
    outline: none;
}

.btn-aplicar {
    padding: 10px 15px;
    background: #28a745;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    white-space: nowrap;
}

.btn-aplicar:hover {
    background: #218838;
}

.direccion-section {
    margin: 15px 0;
}

.direccion-section label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #333;
}

.direccion-section textarea {
    width: 100%;
    padding: 10px;
    border: 2px solid #e1e1e1;
    border-radius: 5px;
    resize: vertical;
    font-family: inherit;
}

.direccion-section textarea:focus {
    border-color: #004aad;
    outline: none;
}

.btn-realizar-pedido {
    width: 100%;
    padding: 15px;
    background: #004aad;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 15px;
    transition: background 0.3s;
}

.btn-realizar-pedido:hover {
    background: #003a8a;
}

.btn-realizar-pedido:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.mensaje-vacio {
    text-align: center;
    padding: 40px 20px;
    color: #999;
}

.mensaje-vacio i {
    font-size: 48px;
    margin-bottom: 15px;
    opacity: 0.5;
}

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 2000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 10px;
    padding: 30px;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.modal-header h3 {
    margin: 0;
}

.close-modal {
    font-size: 24px;
    cursor: pointer;
    color: #999;
}

.close-modal:hover {
    color: #333;
}

.producto-detalle-imagen {
    width: 100%;
    max-height: 300px;
    object-fit: cover;
    border-radius: 10px;
    margin-bottom: 20px;
}

.producto-detalle-precio {
    font-size: 28px;
    color: #004aad;
    font-weight: bold;
    margin: 15px 0;
}

.producto-detalle-cantidad {
    display: flex;
    align-items: center;
    gap: 15px;
    margin: 20px 0;
}

.producto-detalle-cantidad label {
    font-weight: 500;
}

/* Botón categorías para mobile */
.btn-categorias-mobile {
    display: none;
    position: fixed;
    bottom: 20px;
    left: 20px;
    width: 60px;
    height: 60px;
    background: #004aad;
    color: white;
    border-radius: 50%;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    box-shadow: 0 4px 15px rgba(0,74,173,0.4);
    cursor: pointer;
    z-index: 1300;
    border: none;
}

.btn-cart-mobile {
    display: none;
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    background: #004aad;
    color: white;
    border-radius: 50%;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    box-shadow: 0 4px 15px rgba(0,74,173,0.4);
    cursor: pointer;
    z-index: 1300;
    border: none;
}

.btn-cart-mobile .cart-count,
.btn-categorias-mobile .cart-count {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ff6b6b;
    color: white;
    border-radius: 50%;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
}

.btn-categorias-mobile .cart-count {
    background: #28a745;
}

/* Overlay para mobile */
.categorias-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1400;
}

.carrito-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1400;
}

@media (max-width: 1200px) {
    .tienda-container {
        grid-template-columns: 1fr 260px 320px;
    }
}

@media (max-width: 992px) {
    .tienda-container {
        grid-template-columns: 1fr;
    }
    
    /* Sidebar categorías en mobile */
    .categorias-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: 280px;
        max-width: 85%;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        z-index: 1501;
        overflow-y: auto;
        border-radius: 0;
        margin: 0;
        position: fixed;
        top: 0;
        left: 0;
        height: 100%;
        z-index: 1501;
    }
    
    .categorias-sidebar.active {
        transform: translateX(0);
    }
    
    /* Carrito en mobile */
    .carrito-sidebar {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        top: auto;
        max-height: 80vh;
        border-radius: 20px 20px 0 0;
        transform: translateY(100%);
        transition: transform 0.3s;
        z-index: 1500;
        overflow-y: auto;
    }
    
    .carrito-sidebar.active {
        transform: translateY(0);
    }
    
    .carrito-overlay.active,
    .categorias-overlay.active {
        display: block;
    }
    
    .btn-categorias-mobile {
        display: flex;
    }
    
    .btn-cart-mobile {
        display: flex;
    }
    
    .productos-grid{
         margin-left: 0;
    }
}

.alert {
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 15px;
}

.alert-success {
    background: #d4edda;
    color: #155724;
}

.alert-error {
    background: #f8d7da;
    color: #721c24;
}