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

/* ================================================================
   TOKENS CLIENTE (MODO OSCURO)
================================================================ */
:root {
    --bg:          #0f1117;
    --bg-surface:  #161b27;
    --bg-surface-2:#1e2535;
    --primary:     #2563eb; 
    --primary-light: rgba(37,99,235,0.15);
    --accent:      #3b82f6;
    --text:        #e8eaf0;
    --text-muted:  #7a8099;
    --border:      #252d3d;
    --danger:      #ef4444;
    --success:     #10b981;
    --warn:        #f59e0b;
    --radius:      10px;
    --shadow:      0 8px 30px rgba(0,0,0,0.4);
    --font:        'Inter', system-ui, sans-serif;
    --mono:        'JetBrains Mono', monospace;
    --transition:  .2s ease;
    --max-w:       1200px;
}

/* ================================================================
   RESET
================================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; background: var(--bg); color: var(--text); font-family: var(--font); }
body { min-height: 100vh; display: flex; flex-direction: column; background: var(--bg); }
a { color: var(--accent); text-decoration: none; transition: .2s; }
a:hover { color: #fff; }
ul { list-style: none; }
button, input, select { font-family: inherit; }

/* ================================================================
   HEADER
================================================================ */
.header {
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 100;
    backdrop-filter: blur(10px);
}
.header-inner {
    max-width: var(--max-w);
    margin: 0 auto;
    padding: 0 20px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.brand { display: flex; align-items: center; }
.brand-logo-wrapper {
    height: 40px;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}
.brand:hover .brand-logo-wrapper {
    transform: scale(1.05);
}
.brand-logo {
    height: 100%;
    width: auto;
    object-fit: contain;
    /* Ajuste para eliminar fondo blanco en modo oscuro */
    filter: brightness(1.1) contrast(1.5) invert(1) contrast(1.5);
    mix-blend-mode: screen;
}
.nav-menu { display: flex; gap: 24px; align-items: center; }
.nav-link { color: var(--text-muted); font-weight: 600; font-size: .9rem; transition: color var(--transition); }
.nav-link:hover, .nav-link.active { color: var(--primary); }

.user-menu { display: flex; align-items: center; gap: 16px; border-left: 1px solid var(--border); padding-left: 16px; }

/* ================================================================
   MAIN LAYOUT
================================================================ */
.main { flex: 1; padding: 40px 20px; }
.container { max-width: var(--max-w); margin: 0 auto; }
.page-header { margin-bottom: 24px; display: flex; justify-content: space-between; align-items: flex-end; }
.page-title { font-size: 1.7rem; font-weight: 800; color: #fff; letter-spacing: -0.02em; }
.page-subtitle { color: var(--text-muted); margin-top: 4px; font-size: .9rem; }

/* ================================================================
   COMPONENTS
================================================================ */
.card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}
.card-body { padding: 24px; }
.card-header { padding: 18px 24px; border-bottom: 1px solid var(--border); font-weight: 700; font-size: 1rem; color: #fff; background: rgba(255,255,255,0.02); }

.btn {
    display: inline-flex; align-items: center; gap: 8px; justify-content: center;
    padding: 11px 22px; font-weight: 600; font-size: .9rem;
    border-radius: var(--radius); cursor: pointer; transition: all var(--transition); border: none;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: #3a6fd8; transform: scale(1.02); }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { background: var(--bg-surface-2); border-color: var(--primary); }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--bg-surface-2); color: #fff; }

/* ================================================================
   TABLE
================================================================ */
.table-wrap { overflow-x: auto; width: 100%; }
table { width: 100%; border-collapse: collapse; font-size: .875rem; }
th { padding: 12px 16px; text-align: left; background: rgba(255,255,255,0.03); border-bottom: 1px solid var(--border); color: var(--text-muted); font-weight: 700; text-transform: uppercase; font-size: .7rem; letter-spacing: .08em; }
td { padding: 16px; border-bottom: 1px solid var(--border); vertical-align: middle; color: var(--text); }
tr:hover td { background: rgba(255,255,255,0.01); }
tr:last-child td { border-bottom: none; }

/* ================================================================
   BADGES
================================================================ */
.badge { padding: 4px 10px; border-radius: 6px; font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.02em; }
.badge-muted { background: var(--bg-surface-2); color: var(--text-muted); }
.badge-warn  { background: rgba(245,158,11,0.15); color: #fbbf24; }
.badge-success { background: rgba(16,185,129,0.15); color: #34d399; }
.badge-info { background: var(--primary-light); color: var(--primary); }

/* ================================================================
   FORMS & MISC
================================================================ */
.form-group { margin-bottom: 20px; }
.form-label { display: block; font-weight: 600; margin-bottom: 8px; font-size: .85rem; color: var(--text-muted); }
.form-control { 
    width: 100%; padding: 11px 15px; background: var(--bg-surface-2); 
    border: 1px solid var(--border); border-radius: 8px; color: #fff; 
    font-size: .95rem; transition: .2s; outline: none;
}
.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(79,142,247,0.15); }

.alert { padding: 14px 18px; border-radius: var(--radius); margin-bottom: 24px; font-size: .9rem; border: 1px solid transparent; }
.alert-error { background: rgba(239,68,68,0.1); border-color: rgba(239,68,68,0.2); color: #f87171; }
.alert-success { background: rgba(16,185,129,0.1); border-color: rgba(16,185,129,0.2); color: #34d399; }

.text-right { text-align: right; }
.text-muted { color: var(--text-muted); }
.mono { font-family: var(--mono); font-size: .82rem; }
.bold { font-weight: 700; }
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-muted); }

/* AUTH MODERN UX/UI */
.auth-wrapper { 
    min-height: 100vh; display: grid; place-items: center; padding: 20px;
    background: var(--bg); 
    background-image: 
        radial-gradient(circle at 15% 15%, rgba(79,142,247,0.12) 0%, transparent 45%),
        radial-gradient(circle at 85% 85%, rgba(16,185,129,0.06) 0%, transparent 45%);
}
.auth-box { 
    background: var(--bg-surface); padding: 40px; border-radius: 20px; 
    border: 1px solid var(--border); box-shadow: 0 20px 50px rgba(0,0,0,0.5); width: 100%; max-width: 440px; 
    backdrop-filter: blur(16px);
    animation: fadeInUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.input-group-icon {
    position: relative;
    display: flex;
    align-items: center;
}
.input-group-icon .input-icon {
    position: absolute;
    left: 14px;
    color: var(--text-muted);
    width: 20px;
    height: 20px;
    pointer-events: none;
    transition: color 0.2s;
}
.input-group-icon .form-control {
    padding-left: 44px;
    padding-right: 44px;
}
.input-group-icon .form-control:focus ~ .input-icon {
    color: var(--primary);
}

.toggle-password-btn {
    position: absolute;
    right: 12px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: color 0.2s, background 0.2s;
}
.toggle-password-btn:hover {
    color: #fff;
    background: rgba(255,255,255,0.08);
}
.toggle-password-btn svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.btn-loading {
    pointer-events: none;
    opacity: 0.85;
}
.btn-spinner {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-right: 8px;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}

/* UNIFIED CART */
.cart-trigger { 
    position: relative; 
    color: var(--text-muted); 
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 6px 10px;
    background: transparent;
    border: none;
    border-radius: 12px;
    transition: var(--transition);
}
.cart-trigger:hover, .cart-trigger.active {
    color: white;
    background: rgba(255, 255, 255, 0.05);
}
.cart-label { font-size: 0.9rem; font-weight: 600; }
.cart-badge {
    position: absolute; 
    top: -4px; 
    right: -4px; 
    background: var(--accent);
    color: white; 
    font-size: 0.75rem; 
    font-weight: 800; 
    min-width: 18px;
    height: 18px; 
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    border: none;
    line-height: 1;
    padding-top: 1px;
}

/* SCROLLBAR */
::-webkit-scrollbar { width: 7px; height: 7px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }

/* Modal System */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.85);
    backdrop-filter: blur(15px); z-index: 2000;
    display: grid; place-items: center; padding: 20px;
}
.modal {
    width: 100%; max-width: 900px; background: var(--surface);
    border: 1px solid var(--border); border-radius: var(--radius-lg);
    overflow: hidden; box-shadow: var(--shadow-lg);
}

/* ==========================================================================
   B2B SUPPORT WIDGET (Burbuja de Contacto)
   ========================================================================== */
.b2b-support-widget {
    position: fixed; bottom: 30px; right: 30px; z-index: 9000;
}

.support-trigger {
    width: 64px; height: 64px; border-radius: 50%;
    background: var(--primary); color: white;
    display: grid; place-items: center; cursor: pointer;
    box-shadow: 0 10px 30px rgba(79,142,247,0.4);
    transition: var(--transition); border: 2px solid rgba(255,255,255,0.1);
    position: relative;
}
.support-trigger:hover { transform: scale(1.1) rotate(5deg); background: #3b7ad6; }

.trigger-icon { font-size: 1.8rem; }
.trigger-badge {
    position: absolute; top: 2px; right: 2px;
    width: 14px; height: 14px; background: var(--success);
    border: 3px solid var(--primary); border-radius: 50%;
}
.trigger-badge::after {
    content: '';
    position: absolute; inset: -3px;
    border-radius: 50%;
    background: var(--success);
    opacity: 0.6;
    animation: badgePulse 2s cubic-bezier(0, 0, 0.2, 1) infinite;
    z-index: -1;
}

@keyframes badgePulse {
    0% { transform: scale(1); opacity: 0.8; }
    70% { transform: scale(2.2); opacity: 0; }
    100% { transform: scale(1); opacity: 0; }
}

.support-menu {
    position: absolute; bottom: 80px; right: 0;
    width: 300px; background: var(--bg-surface);
    border: 1px solid var(--border); border-radius: 20px;
    padding: 20px; box-shadow: var(--shadow);
    display: flex; flex-direction: column; gap: 16px;
    opacity: 0; pointer-events: none; transform: translateY(20px) scale(0.95);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.b2b-support-widget.active .support-menu {
    opacity: 1; pointer-events: all; transform: translateY(0) scale(1);
}

.support-header strong { display: block; font-size: 1rem; color: white; margin-bottom: 2px; }
.support-header span { font-size: 0.8rem; color: var(--text-muted); }

.support-options { display: flex; flex-direction: column; gap: 10px; }

.support-opt {
    display: flex; align-items: center; gap: 14px;
    padding: 14px; border-radius: 14px; background: var(--bg-surface-2);
    border: 1px solid var(--border); transition: var(--transition);
}
.support-opt:hover {
    transform: translateX(4px); border-color: var(--primary);
    background: var(--primary-light);
}

.support-opt.whatsapp .opt-icon { font-size: 1.5rem; }
.support-opt.call .opt-icon { font-size: 1.5rem; }

.opt-text strong { display: block; font-size: 0.88rem; color: white; }
.opt-text span { font-size: 0.75rem; color: var(--text-muted); }
