:root {
    --primary: #0d6efd;
    --primary-dark: #0a58ca;
    --secondary: #6c757d;
    --success: #198754;
    --danger: #dc3545;
    --warning: #ffc107;
    --dark: #1a1a2e;
    --dark-secondary: #16213e;
    --accent: #0f3460;
    --light-bg: #f8f9fa;
    --card-shadow: 0 4px 20px rgba(0,0,0,0.08);
    --transition: all 0.3s ease;
}

* { box-sizing: border-box; }

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background-color: var(--light-bg);
    color: #333;
}

/* ===== NAVBAR ===== */
.navbar-brand {
    font-weight: 700;
    font-size: 1.4rem;
    letter-spacing: -0.5px;
}

.navbar-brand span { color: var(--warning); }

/* ===== HERO ===== */
.hero-section {
    background: linear-gradient(135deg, var(--dark) 0%, var(--accent) 100%);
    color: white;
    padding: 80px 0;
    position: relative;
    overflow: hidden;
}

.hero-section::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -10%;
    width: 500px;
    height: 500px;
    background: rgba(255,255,255,0.03);
    border-radius: 50%;
}

/* ===== CARDS ===== */
.product-card {
    border: none;
    border-radius: 12px;
    box-shadow: var(--card-shadow);
    transition: var(--transition);
    overflow: hidden;
    height: 100%;
}

.product-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 30px rgba(0,0,0,0.15);
}

/* Contenedor de imagen: altura fija, imagen centrada y recortada */
.product-img-wrap {
    position: relative;
    height: 200px;
    overflow: hidden;
    background: #f0f4ff;
}

.product-img-wrap img.product-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    transition: transform 0.4s ease;
    display: block;
}

.product-card:hover .product-img {
    transform: scale(1.05);
}

/* Fallback cuando no hay imagen: ícono centrado */
.product-img-wrap .product-img-icon {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3.5rem;
    color: #adb5bd;
}

/* Ribbon de categoría sobre la imagen */
.product-img-wrap .product-category-ribbon {
    position: absolute;
    top: 10px;
    left: 10px;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    backdrop-filter: blur(4px);
}

/* ===== CLASES DINÁMICAS POR CATEGORÍA ===== */
/* Cada categoría tiene su propio color de acento */

.cat-smartphones .product-img-wrap  { background: linear-gradient(135deg, #e8f4fd, #d0e8fb); }
.cat-smartphones .product-img-icon  { color: #0d6efd; }
.cat-smartphones .product-category-ribbon { background: rgba(13,110,253,0.15); color: #0d6efd; }
.cat-smartphones .btn-cart          { background: linear-gradient(135deg, #0d6efd, #0a58ca); }

.cat-laptops .product-img-wrap      { background: linear-gradient(135deg, #e8fdf0, #d0f5e0); }
.cat-laptops .product-img-icon      { color: #198754; }
.cat-laptops .product-category-ribbon { background: rgba(25,135,84,0.15); color: #198754; }
.cat-laptops .btn-cart              { background: linear-gradient(135deg, #198754, #146c43); }

.cat-audio .product-img-wrap        { background: linear-gradient(135deg, #fdf3e8, #fbe3c8); }
.cat-audio .product-img-icon        { color: #fd7e14; }
.cat-audio .product-category-ribbon { background: rgba(253,126,20,0.15); color: #fd7e14; }
.cat-audio .btn-cart                { background: linear-gradient(135deg, #fd7e14, #e96b00); }

.cat-tablets .product-img-wrap      { background: linear-gradient(135deg, #f3e8fd, #e5d0fb); }
.cat-tablets .product-img-icon      { color: #6f42c1; }
.cat-tablets .product-category-ribbon { background: rgba(111,66,193,0.15); color: #6f42c1; }
.cat-tablets .btn-cart              { background: linear-gradient(135deg, #6f42c1, #5a32a3); }

.cat-accesorios .product-img-wrap   { background: linear-gradient(135deg, #fdf8e8, #faf0c8); }
.cat-accesorios .product-img-icon   { color: #d4a017; }
.cat-accesorios .product-category-ribbon { background: rgba(212,160,23,0.15); color: #b8860b; }
.cat-accesorios .btn-cart           { background: linear-gradient(135deg, #d4a017, #b8860b); }

/* Clase genérica para categorías no mapeadas */
.cat-default .product-img-wrap      { background: linear-gradient(135deg, #f0f4ff, #e0e8ff); }
.cat-default .product-img-icon      { color: #6c757d; }
.cat-default .product-category-ribbon { background: rgba(108,117,125,0.15); color: #6c757d; }
.cat-default .btn-cart              { background: linear-gradient(135deg, #6c757d, #495057); }

/* Overlay agotado sobre la imagen */
.product-img-wrap .overlay-agotado {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    font-weight: 700;
    color: white;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.badge-stock-bajo { background-color: var(--warning); color: #000; }
.badge-agotado { background-color: var(--danger); }

/* Miniatura en tabla admin */
.product-thumb {
    width: 52px;
    height: 52px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid #e9ecef;
    background: #f8f9fa;
}

/* ===== BOTONES ===== */
.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
    border-radius: 8px;
    font-weight: 500;
    transition: var(--transition);
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
}

.btn-cart {
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: white;
    border: none;
    border-radius: 8px;
    padding: 8px 16px;
    font-weight: 500;
    transition: var(--transition);
}

.btn-cart:hover {
    opacity: 0.9;
    transform: translateY(-1px);
    color: white;
}

/* ===== LOGIN / REGISTER ===== */
.auth-wrapper {
    min-height: 100vh;
    background: linear-gradient(135deg, var(--dark) 0%, var(--accent) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.auth-card {
    background: white;
    border-radius: 16px;
    padding: 40px;
    width: 100%;
    max-width: 440px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.auth-card .logo {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--dark);
    text-align: center;
    margin-bottom: 8px;
}

.auth-card .logo span { color: var(--primary); }

.form-control {
    border-radius: 8px;
    border: 1.5px solid #dee2e6;
    padding: 10px 14px;
    transition: var(--transition);
}

.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(13,110,253,0.15);
}

/* ===== ADMIN SIDEBAR ===== */
.admin-wrapper { display: flex; min-height: 100vh; }

.sidebar {
    width: 260px;
    background: linear-gradient(180deg, var(--dark) 0%, var(--dark-secondary) 100%);
    color: white;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 1000;
    transition: var(--transition);
}

.sidebar-brand {
    padding: 24px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    font-size: 1.2rem;
    font-weight: 700;
}

.sidebar-brand span { color: var(--warning); }

.sidebar-nav { padding: 16px 0; }

.sidebar-nav .nav-item { margin: 2px 12px; }

.sidebar-nav .nav-link {
    color: rgba(255,255,255,0.7);
    border-radius: 8px;
    padding: 10px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: var(--transition);
    font-size: 0.9rem;
}

.sidebar-nav .nav-link:hover,
.sidebar-nav .nav-link.active {
    background: rgba(255,255,255,0.1);
    color: white;
}

.sidebar-nav .nav-link i { width: 18px; text-align: center; }

.admin-content {
    margin-left: 260px;
    flex: 1;
    padding: 0;
}

.admin-topbar {
    background: white;
    padding: 16px 28px;
    border-bottom: 1px solid #e9ecef;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

.admin-main { padding: 28px; }

/* ===== STATS CARDS ===== */
.stat-card {
    border: none;
    border-radius: 12px;
    padding: 24px;
    color: white;
    position: relative;
    overflow: hidden;
}

.stat-card::after {
    content: '';
    position: absolute;
    top: -20px;
    right: -20px;
    width: 100px;
    height: 100px;
    background: rgba(255,255,255,0.1);
    border-radius: 50%;
}

.stat-card .stat-icon {
    font-size: 2rem;
    opacity: 0.8;
    position: relative;
    z-index: 1;
}

.stat-card .stat-value {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1;
    position: relative;
    z-index: 1;
}

.stat-card .stat-label {
    font-size: 0.85rem;
    opacity: 0.85;
    position: relative;
    z-index: 1;
}

.bg-gradient-primary { background: linear-gradient(135deg, #0d6efd, #0a58ca); }
.bg-gradient-success { background: linear-gradient(135deg, #198754, #146c43); }
.bg-gradient-warning { background: linear-gradient(135deg, #ffc107, #e0a800); color: #000 !important; }
.bg-gradient-danger  { background: linear-gradient(135deg, #dc3545, #b02a37); }

/* ===== TABLAS ===== */
.table-custom { border-radius: 12px; overflow: hidden; box-shadow: var(--card-shadow); }
.table-custom thead { background: var(--dark); color: white; }
.table-custom tbody tr:hover { background: rgba(13,110,253,0.04); }

/* ===== ALERTAS ===== */
.alert-stock-badge {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* ===== CARRITO ===== */
.cart-item {
    border: 1px solid #e9ecef;
    border-radius: 10px;
    padding: 16px;
    margin-bottom: 12px;
    background: white;
    transition: var(--transition);
}

.cart-item:hover { box-shadow: var(--card-shadow); }

/* ===== CHATBOT ===== */
.chatbot-toggle {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: white;
    border: none;
    border-radius: 50%;
    font-size: 1.4rem;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(13,110,253,0.4);
    z-index: 9999;
    transition: var(--transition);
}

.chatbot-toggle:hover { transform: scale(1.1); }

.chatbot-window {
    position: fixed;
    bottom: 90px;
    right: 24px;
    width: 340px;
    height: 460px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    z-index: 9998;
    display: none;
    flex-direction: column;
    overflow: hidden;
}

.chatbot-window.open { display: flex; }

.chatbot-header {
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: white;
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.chat-msg {
    max-width: 80%;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 0.875rem;
    line-height: 1.4;
}

.chat-msg.bot {
    background: #f0f4ff;
    color: #333;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

.chat-msg.user {
    background: var(--primary);
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.chatbot-input {
    padding: 12px;
    border-top: 1px solid #e9ecef;
    display: flex;
    gap: 8px;
}

.chatbot-input input {
    flex: 1;
    border: 1.5px solid #dee2e6;
    border-radius: 20px;
    padding: 8px 14px;
    font-size: 0.875rem;
    outline: none;
}

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

.chatbot-input button {
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    cursor: pointer;
    transition: var(--transition);
}

.chatbot-input button:hover { background: var(--primary-dark); }

/* ===== FOOTER ===== */
.footer {
    background: var(--dark);
    color: rgba(255,255,255,0.7);
    padding: 40px 0 20px;
    margin-top: 60px;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .admin-content { margin-left: 0; }
    .chatbot-window { width: calc(100vw - 32px); right: 16px; }
}
