/* ============================================================
   AS Solutions - Estilos Globales
   Diseño Mobile-First / Progressive Enhancement
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800;900&family=Syne:wght@700;800&display=swap');

:root {
    --brand:       #6366f1;
    --brand-dark:  #4f46e5;
    --brand-light: #e0e7ff;
    --accent:      #f59e0b;
    --success:     #10b981;
    --danger:      #ef4444;
    --warning:     #f59e0b;
    --bg:          #f1f5f9;
    --surface:     #ffffff;
    --surface2:    #f8fafc;
    --border:      #e2e8f0;
    --text:        #0f172a;
    --text-muted:  #64748b;
    --sidebar-w:   260px;
    --radius-lg:   1.5rem;
    --radius-xl:   2rem;
    --shadow-sm:   0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
    --shadow-md:   0 4px 16px rgba(0,0,0,.08);
    --shadow-lg:   0 12px 40px rgba(0,0,0,.12);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { height: 100%; -webkit-text-size-adjust: 100%; }

body {
    font-family: 'Plus Jakarta Sans', sans-serif;
    background: var(--bg);
    color: var(--text);
    height: 100%;
    overflow: hidden;
}

/* ── SCROLLBAR ───────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ── APP SHELL ───────────────────────────────────── */
#app-shell {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* ── SIDEBAR ─────────────────────────────────────── */
#sidebar {
    width: var(--sidebar-w);
    min-width: var(--sidebar-w);
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    transition: transform .3s cubic-bezier(.4,0,.2,1), width .3s;
    z-index: 100;
    overflow-y: auto;
}

#sidebar .brand-logo {
    width: 36px;
    height: 36px;
    object-fit: contain;
    border-radius: 8px;
}

#sidebar .brand-initial {
    width: 36px;
    height: 36px;
    background: var(--brand);
    color: white;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Syne', sans-serif;
    font-weight: 800;
    font-size: 1rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .7rem 1rem;
    border-radius: .875rem;
    cursor: pointer;
    font-size: .875rem;
    font-weight: 600;
    color: var(--text-muted);
    transition: all .15s ease;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    text-decoration: none;
}
.nav-item:hover { background: var(--brand-light); color: var(--brand); }
.nav-item.active { background: var(--brand); color: white; }
.nav-item .nav-icon { width: 18px; height: 18px; flex-shrink: 0; }
.nav-item .badge {
    margin-left: auto;
    background: var(--danger);
    color: white;
    font-size: .65rem;
    padding: .1rem .4rem;
    border-radius: 999px;
    font-weight: 700;
}

/* ── MAIN CONTENT ────────────────────────────────── */
#main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow: hidden;
}

#topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    gap: 1rem;
    flex-shrink: 0;
}

#topbar .page-title {
    font-family: 'Syne', sans-serif;
    font-size: 1.35rem;
    font-weight: 800;
    color: var(--text);
    line-height: 1.1;
}

#topbar .page-subtitle {
    font-size: .75rem;
    color: var(--text-muted);
    margin-top: .1rem;
}

.user-chip {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .4rem .9rem .4rem .4rem;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 999px;
    cursor: pointer;
    transition: all .15s;
}
.user-chip:hover { border-color: var(--brand); }
.user-avatar {
    width: 32px;
    height: 32px;
    background: var(--brand);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .75rem;
    font-weight: 800;
}
.user-name { font-size: .8rem; font-weight: 700; }
.user-role { font-size: .65rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; }

#page-content {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
}

/* ── HAMBURGER (mobile) ──────────────────────────── */
#hamburger {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: .4rem;
    color: var(--text);
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.4);
    z-index: 99;
}

/* ── CARDS ───────────────────────────────────────── */
.card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    padding: 1.5rem;
}
.card-title {
    font-family: 'Syne', sans-serif;
    font-size: 1rem;
    font-weight: 800;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: .5rem;
}

/* ── STAT CARD ───────────────────────────────────── */
.stat-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    padding: 1.25rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: .5rem;
    transition: transform .2s, box-shadow .2s;
    cursor: default;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-icon { width: 40px; height: 40px; border-radius: .75rem; display: flex; align-items: center; justify-content: center; }
.stat-label { font-size: .75rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; }
.stat-value { font-family: 'Syne', sans-serif; font-size: 1.75rem; font-weight: 800; line-height: 1; }
.stat-sub { font-size: .75rem; color: var(--text-muted); }

/* ── BUTTONS ─────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    padding: .6rem 1.2rem;
    border-radius: .875rem;
    font-size: .875rem;
    font-weight: 700;
    border: none;
    cursor: pointer;
    transition: all .15s ease;
    text-decoration: none;
    white-space: nowrap;
}
.btn-primary { background: var(--brand); color: white; }
.btn-primary:hover { background: var(--brand-dark); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(99,102,241,.3); }
.btn-secondary { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-danger { background: #fef2f2; color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: white; }
.btn-success { background: #ecfdf5; color: var(--success); }
.btn-success:hover { background: var(--success); color: white; }
.btn-icon { padding: .55rem; border-radius: .75rem; }
.btn-sm { padding: .4rem .85rem; font-size: .8rem; border-radius: .75rem; }
.btn-lg { padding: .85rem 2rem; font-size: 1rem; border-radius: 1rem; }
.btn-full { width: 100%; justify-content: center; }

/* ── FORMS ───────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: .4rem; }
.form-label { font-size: .8rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; }
.form-input, .form-select, .form-textarea {
    padding: .7rem 1rem;
    border: 1.5px solid var(--border);
    border-radius: .875rem;
    font-size: .9rem;
    font-family: inherit;
    background: var(--surface);
    color: var(--text);
    outline: none;
    transition: border-color .15s;
    width: 100%;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(99,102,241,.1);
}

/* ── TABLE ───────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th { font-size: .73rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); padding: .75rem 1rem; text-align: left; border-bottom: 2px solid var(--border); white-space: nowrap; }
tbody td { padding: .85rem 1rem; border-bottom: 1px solid var(--border); font-size: .875rem; vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--surface2); }

/* ── BADGE ───────────────────────────────────────── */
.badge { display: inline-flex; align-items: center; padding: .25rem .65rem; border-radius: 999px; font-size: .7rem; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; }
.badge-green  { background: #d1fae5; color: #065f46; }
.badge-red    { background: #fee2e2; color: #991b1b; }
.badge-yellow { background: #fef3c7; color: #92400e; }
.badge-blue   { background: #dbeafe; color: #1e40af; }
.badge-purple { background: #ede9fe; color: #4c1d95; }
.badge-gray   { background: #f1f5f9; color: #475569; }

/* ══════════════════════════════════════════════════
   MODAL — siempre desde arriba, scrolleable
   ══════════════════════════════════════════════════ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15,23,42,.55);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 1000;
    display: flex;
    align-items: flex-start;        /* siempre desde arriba */
    justify-content: center;
    padding: 1rem;
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s ease;
    overflow-y: auto;               /* scroll si el contenido es largo */
    -webkit-overflow-scrolling: touch;
}
.modal-overlay.open {
    opacity: 1;
    pointer-events: all;
}

.modal-box {
    background: var(--surface);
    border-radius: 1.25rem;
    width: 100%;
    max-width: 520px;
    padding: 1.75rem 1.5rem;
    box-shadow: 0 24px 64px rgba(0,0,0,.18), 0 8px 24px rgba(0,0,0,.1);
    position: relative;
    transform: translateY(16px);
    transition: transform .25s cubic-bezier(.4,0,.2,1);
    margin: 1rem auto;              /* margen arriba para que no pegue al borde */
    flex-shrink: 0;
}
.modal-overlay.open .modal-box {
    transform: translateY(0);
}

.modal-title {
    font-family: 'Syne', sans-serif;
    font-size: 1.2rem;
    font-weight: 800;
    margin-bottom: 1.25rem;
    padding-right: 2.5rem;
}

.modal-close {
    position: absolute;
    top: 1.25rem;
    right: 1.25rem;
    background: var(--surface2);
    border: 1.5px solid var(--border);
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: .625rem;
    font-size: 1rem;
    line-height: 1;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all .15s;
    z-index: 2;
}
.modal-close:hover {
    background: var(--danger);
    color: white;
    border-color: var(--danger);
}

/* ── GRID HELPERS ────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3,1fr); gap: 1rem; }
.grid-4 { display: grid; grid-template-columns: repeat(4,1fr); gap: 1rem; }
.grid-auto { display: grid; grid-template-columns: repeat(auto-fill,minmax(200px,1fr)); gap: 1rem; }

/* ── PRODUCT CARD ────────────────────────────────── */
.producto-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: all .2s;
    cursor: pointer;
}
.producto-card:hover { border-color: var(--brand); box-shadow: var(--shadow-md); transform: translateY(-2px); }
.producto-card-img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    background: var(--surface2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
}
.producto-card-body { padding: .875rem; }
.producto-card-name { font-weight: 700; font-size: .875rem; margin-bottom: .25rem; }
.producto-card-sku { font-size: .7rem; color: var(--text-muted); font-weight: 600; font-family: monospace; margin-bottom: .5rem; }
.producto-card-price { font-family: 'Syne', sans-serif; font-size: 1.1rem; font-weight: 800; color: var(--brand); }

/* ── TALLA GRID (inventario) ─────────────────────── */
.talla-grid { display: grid; grid-template-columns: repeat(6,1fr); gap: .4rem; }
.talla-chip {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: .5rem .25rem;
    background: var(--surface2);
    border: 1.5px solid var(--border);
    border-radius: .625rem;
    gap: .15rem;
}
.talla-chip label { font-size: .65rem; font-weight: 800; color: var(--text-muted); text-transform: uppercase; }
.talla-chip input {
    width: 100%;
    border: none;
    background: transparent;
    text-align: center;
    font-size: .9rem;
    font-weight: 800;
    font-family: 'Plus Jakarta Sans', sans-serif;
    outline: none;
    color: var(--text);
}

/* ── POS CARRITO ─────────────────────────────────── */
.carrito-item {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .75rem;
    background: rgba(255,255,255,.05);
    border: 1px solid rgba(255,255,255,.1);
    border-radius: 1rem;
}
.carrito-qty {
    width: 52px;
    background: rgba(255,255,255,.1);
    border: 1px solid rgba(255,255,255,.2);
    color: white;
    border-radius: .5rem;
    padding: .3rem;
    text-align: center;
    font-weight: 800;
    font-size: .9rem;
    outline: none;
}

/* ── TOAST ───────────────────────────────────────── */
#toast-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: .5rem;
}
.toast {
    background: var(--text);
    color: white;
    padding: .75rem 1.25rem;
    border-radius: 1rem;
    font-size: .875rem;
    font-weight: 600;
    box-shadow: var(--shadow-lg);
    animation: slideUp .3s ease;
    max-width: 320px;
}
.toast.success { background: var(--success); }
.toast.error   { background: var(--danger); }
.toast.warning { background: var(--warning); color: var(--text); }
@keyframes slideUp { from { opacity:0; transform:translateY(20px); } to { opacity:1; transform:translateY(0); } }

/* ── LOGIN PAGE ──────────────────────────────────── */
#login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 1.5rem;
}
.login-card {
    background: white;
    border-radius: var(--radius-xl);
    padding: 2.5rem 2rem;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-lg);
}
.login-brand { display: flex; align-items: center; gap: .75rem; margin-bottom: 2rem; }
.login-brand-icon { width: 48px; height: 48px; background: var(--brand); border-radius: .875rem; display: flex; align-items: center; justify-content: center; color: white; font-family: 'Syne', sans-serif; font-weight: 800; font-size: 1.25rem; }
.login-title { font-family: 'Syne', sans-serif; font-size: 1.5rem; font-weight: 800; }
.login-sub { font-size: .85rem; color: var(--text-muted); margin-top: .15rem; }

/* ── RESPONSIVE ──────────────────────────────────── */
@media (max-width: 768px) {
    #sidebar {
        position: fixed;
        top: 0; left: 0; bottom: 0;
        transform: translateX(-100%);
        box-shadow: var(--shadow-lg);
    }
    #sidebar.open { transform: translateX(0); }
    .sidebar-overlay.open { display: block; }
    #hamburger { display: flex; }
    #page-content { padding: 1rem; }
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
    .talla-grid { grid-template-columns: repeat(3,1fr); }
    .stat-card .stat-value { font-size: 1.4rem; }
    #topbar { padding: .75rem 1rem; }
    #topbar .page-title { font-size: 1.1rem; }
    .modal-box {
        padding: 1.25rem 1rem;
        margin: .5rem auto;
        max-width: 100%;
        border-radius: 1.25rem;
    }
    .btn-lg { padding: .75rem 1.5rem; }
}

@media (max-width: 480px) {
    .grid-auto { grid-template-columns: repeat(2,1fr); }
    .producto-card-img { font-size: 1.75rem; }
    .modal-overlay {
        padding: .5rem;
    }
    .modal-box {
        margin: .25rem auto;
        border-radius: 1.25rem 1.25rem 0 0;
    }
}

/* ── ANIMACIONES ─────────────────────────────────── */
.animate-in { animation: fadeInUp .35s cubic-bezier(.4,0,.2,1) both; }
@keyframes fadeInUp { from { opacity:0; transform:translateY(16px); } to { opacity:1; transform:translateY(0); } }

/* ── ESTADO VACÍO ────────────────────────────────── */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
    text-align: center;
    gap: .75rem;
}
.empty-state svg { opacity: .3; }
.empty-state h3 { font-weight: 700; color: var(--text); }

/* ── LOADING ─────────────────────────────────────── */
.spinner {
    width: 32px; height: 32px;
    border: 3px solid var(--brand-light);
    border-top-color: var(--brand);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-center { display: flex; align-items: center; justify-content: center; min-height: 200px; }

/* ── SEARCH BAR ──────────────────────────────────── */
.search-bar {
    position: relative;
    display: flex;
    align-items: center;
}
.search-bar svg {
    position: absolute;
    left: .875rem;
    color: var(--text-muted);
    pointer-events: none;
}
.search-bar input {
    padding-left: 2.75rem;
    background: var(--surface2);
    border-color: transparent;
}
.search-bar input:focus { background: var(--surface); }

/* ── CHART ───────────────────────────────────────── */
.chart-bar-row { display: flex; align-items: center; gap: .75rem; margin-bottom: .75rem; }
.chart-bar-label { font-size: .8rem; font-weight: 600; width: 120px; flex-shrink: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chart-bar-track { flex: 1; background: var(--surface2); border-radius: 999px; height: 8px; overflow: hidden; }
.chart-bar-fill { height: 100%; background: var(--brand); border-radius: 999px; transition: width .8s cubic-bezier(.4,0,.2,1); }
.chart-bar-val { font-size: .75rem; font-weight: 800; color: var(--text-muted); width: 50px; text-align: right; flex-shrink: 0; }