/* ============================================================
   WMS — Clean Responsive CSS (Final)
   ============================================================ */

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

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --brand:      #2563EB;
    --brand-dk:   #1D4ED8;
    --brand-lt:   #EFF6FF;
    --brand-mid:  #DBEAFE;
    --navy:       #0F172A;
    --sidebar-bg: #0F172A;
    --bg:         #F8FAFC;
    --bg2:        #FFFFFF;
    --bg3:        #F1F5F9;
    --border:     #E2E8F0;
    --border2:    #CBD5E1;
    --text:       #0F172A;
    --text2:      #475569;
    --muted:      #94A3B8;
    --green:      #059669;
    --green-bg:   #ECFDF5;
    --red:        #DC2626;
    --red-bg:     #FEF2F2;
    --amber:      #D97706;
    --amber-bg:   #FFFBEB;
    --sidebar-w:  220px;
    --topbar-h:   56px;
    --radius:     8px;
    --radius-lg:  12px;
    --shadow-sm:  0 1px 2px rgba(0,0,0,0.05);
    --shadow:     0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md:  0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
    --shadow-lg:  0 10px 15px rgba(0,0,0,0.1), 0 4px 6px rgba(0,0,0,0.05);
}

html { height: 100%; }
body {
    font-family: 'Plus Jakarta Sans', sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    min-height: 100%;
}

/* ── TOPBAR (mobile only) ─────────────────────────── */
.topbar {
    display: none;
    position: fixed; top: 0; left: 0; right: 0;
    height: var(--topbar-h);
    background: var(--sidebar-bg);
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    z-index: 200;
}
.topbar-brand { display: flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 700; color: #fff; }
.hamburger { background: none; border: none; cursor: pointer; padding: 8px; display: flex; flex-direction: column; gap: 5px; border-radius: 6px; }
.hamburger .bar { width: 20px; height: 2px; background: #fff; border-radius: 2px; transition: all 0.3s; }
.hamburger.open .bar:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger.open .bar:nth-child(2) { opacity: 0; }
.hamburger.open .bar:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ── OVERLAY ──────────────────────────────────────── */
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 149; opacity: 0; transition: opacity 0.25s; pointer-events: none; }
.sidebar-overlay.active { opacity: 1; pointer-events: auto; }

/* ── LAYOUT ───────────────────────────────────────── */
.layout { display: flex; min-height: 100vh; max-width: 100vw; overflow-x: hidden; }

/* ── SIDEBAR ──────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-w);
    background: var(--sidebar-bg);
    display: flex; flex-direction: column;
    position: fixed; top: 0; left: 0; bottom: 0;
    z-index: 150;
    transition: transform 0.3s cubic-bezier(0.4,0,0.2,1);
    overflow-y: auto;
}
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 20px 16px 18px; border-bottom: 1px solid rgba(255,255,255,0.06); flex-shrink: 0; }
.brand-logo { width: 34px; height: 34px; background: var(--brand); border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 16px; flex-shrink: 0; }
.brand-text { font-size: 15px; font-weight: 700; color: #fff; letter-spacing: -0.2px; }
.brand-version { font-size: 10px; color: rgba(255,255,255,0.3); letter-spacing: 0.5px; margin-top: 1px; }
.sidebar-nav { flex: 1; padding: 12px 8px; }
.nav-section { font-size: 10px; font-weight: 600; letter-spacing: 0.8px; text-transform: uppercase; color: rgba(255,255,255,0.25); padding: 16px 8px 6px; }
.nav-item { display: flex; align-items: center; gap: 9px; padding: 9px 10px; border-radius: 6px; color: rgba(255,255,255,0.55); text-decoration: none; font-size: 13.5px; font-weight: 500; transition: background 0.15s, color 0.15s; margin-bottom: 1px; }
.nav-item:hover { background: rgba(255,255,255,0.06); color: rgba(255,255,255,0.9); }
.nav-item.active { background: var(--brand); color: #fff; }
.nav-icon { font-size: 14px; width: 18px; text-align: center; flex-shrink: 0; }
.sidebar-footer { padding: 12px 14px; border-top: 1px solid rgba(255,255,255,0.06); display: flex; align-items: center; gap: 9px; flex-shrink: 0; }
.user-avatar { width: 32px; height: 32px; background: var(--brand); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; color: #fff; flex-shrink: 0; }
.user-info { flex: 1; min-width: 0; }
.user-name { font-size: 12.5px; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-rol  { font-size: 11px; color: rgba(255,255,255,0.35); text-transform: capitalize; }
.btn-logout { width: 28px; height: 28px; border-radius: 6px; background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.08); display: flex; align-items: center; justify-content: center; color: rgba(255,255,255,0.4); text-decoration: none; font-size: 13px; transition: background 0.15s, color 0.15s; flex-shrink: 0; }
.btn-logout:hover { background: rgba(220,38,38,0.2); color: #f87171; }

/* ── MAIN CONTENT ─────────────────────────────────── */
.main-content { margin-left: var(--sidebar-w); flex: 1; padding: 32px 36px; min-height: 100vh; max-width: calc(100% - var(--sidebar-w)); overflow-x: hidden; }

/* ── PAGE HEADER ──────────────────────────────────── */
.page-header { display: flex; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; gap: 12px; margin-bottom: 24px; }
.page-header h1 { font-size: 20px; font-weight: 700; color: var(--text); letter-spacing: -0.3px; }
.page-header p  { font-size: 13px; color: var(--muted); margin-top: 2px; }

/* ── CARDS ────────────────────────────────────────── */
.card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 20px; box-shadow: var(--shadow-sm); max-width: 100%; }

/* ── STATS ────────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat-card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 18px 20px; box-shadow: var(--shadow-sm); transition: box-shadow 0.2s; }
.stat-card:hover { box-shadow: var(--shadow-md); }
.stat-label { font-size: 12px; font-weight: 500; color: var(--muted); }
.stat-value { font-size: 30px; font-weight: 700; color: var(--text); margin: 6px 0 2px; letter-spacing: -0.5px; }
.stat-sub   { font-size: 12px; color: var(--muted); }
.stat-icon-wrap { width: 36px; height: 36px; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 17px; margin-bottom: 12px; }
.stat-icon-blue  { background: var(--brand-lt); }
.stat-icon-green { background: var(--green-bg); }
.stat-icon-amber { background: var(--amber-bg); }
.stat-icon-red   { background: var(--red-bg); }

/* ── TABLES ───────────────────────────────────────── */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; min-width: 480px; }
thead th { text-align: left; padding: 10px 14px; font-size: 11.5px; font-weight: 600; color: var(--muted); background: var(--bg3); border-bottom: 1px solid var(--border); white-space: nowrap; letter-spacing: 0.3px; }
tbody tr { border-bottom: 1px solid var(--border); transition: background 0.1s; }
tbody tr:hover { background: var(--bg3); }
tbody tr:last-child { border-bottom: none; }
td { padding: 11px 14px; font-size: 13.5px; }

/* ── BADGES ───────────────────────────────────────── */
.badge { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 4px; font-size: 11.5px; font-weight: 600; }
.badge-green { background: var(--green-bg); color: var(--green); }
.badge-red   { background: var(--red-bg);   color: var(--red); }
.badge-blue  { background: var(--brand-lt); color: var(--brand); }
.badge-amber { background: var(--amber-bg); color: var(--amber); }
.badge-muted { background: var(--bg3);      color: var(--muted); }

/* ── BUTTONS ──────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border-radius: var(--radius); font-family: 'Plus Jakarta Sans', sans-serif; font-size: 13.5px; font-weight: 600; cursor: pointer; border: none; text-decoration: none; transition: all 0.15s; white-space: nowrap; letter-spacing: -0.1px; }
.btn:active { transform: scale(0.97); }
.btn-primary   { background: var(--brand); color: #fff; box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--brand-dk); }
.btn-secondary { background: var(--bg2); color: var(--text2); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--bg3); }
.btn-danger    { background: var(--red-bg); color: var(--red); border: 1px solid #fecaca; }
.btn-danger:hover { background: #fee2e2; }
.btn-sm { padding: 5px 11px; font-size: 12.5px; }

/* ── FORMS ────────────────────────────────────────── */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-full { grid-column: 1 / -1; }
.form-group { margin-bottom: 14px; }
.form-label { display: block; font-size: 12.5px; font-weight: 600; color: var(--text2); margin-bottom: 5px; }
.form-control { width: 100%; background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 12px; font-family: 'Plus Jakarta Sans', sans-serif; font-size: 13.5px; color: var(--text); outline: none; transition: border-color 0.15s, box-shadow 0.15s; -webkit-appearance: none; }
.form-control:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(37,99,235,0.1); }
.form-control::placeholder { color: var(--muted); }
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; }

/* ── TOOLBAR ──────────────────────────────────────── */
.toolbar { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
.toolbar-left  { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.toolbar-right { display: flex; align-items: center; gap: 8px; }

/* ── ALERTS ───────────────────────────────────────── */
.alert { padding: 10px 14px; border-radius: var(--radius); font-size: 13.5px; margin-bottom: 14px; }
.alert-success { background: var(--green-bg); border: 1px solid #a7f3d0; color: var(--green); }
.alert-error   { background: var(--red-bg);   border: 1px solid #fecaca; color: var(--red); }

/* ── MODAL ────────────────────────────────────────── */
.modal-backdrop {
    display: none;
    position: fixed; inset: 0;
    background: rgba(15,23,42,0.5);
    z-index: 9999;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.modal-backdrop.active { display: flex; }
.modal { background: var(--bg2); border-radius: var(--radius-lg); width: 100%; max-width: 520px; max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow-lg); animation: modalIn 0.2s ease; }
@keyframes modalIn { from { opacity:0; transform:scale(0.96) translateY(8px); } to { opacity:1; transform:scale(1) translateY(0); } }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px 14px; border-bottom: 1px solid var(--border); }
.modal-title { font-size: 15px; font-weight: 700; color: var(--text); }
.modal-close { width: 28px; height: 28px; border-radius: 6px; background: var(--bg3); border: none; cursor: pointer; font-size: 14px; color: var(--muted); display: flex; align-items: center; justify-content: center; transition: background 0.15s; }
.modal-close:hover { background: var(--red-bg); color: var(--red); }
.modal-body { padding: 18px 20px; }
.modal-footer { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; }

/* ── EMPTY STATE ──────────────────────────────────── */
.empty-state { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty-icon  { font-size: 36px; margin-bottom: 10px; opacity: 0.35; }
.empty-state p { font-size: 13.5px; }

/* ── MISC ─────────────────────────────────────────── */
.divider { height: 1px; background: var(--border); margin: 20px 0; }
.dashboard-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ══════════════════════════════════════════════════
   RESPONSIVE: TABLET
══════════════════════════════════════════════════ */
@media (max-width: 1024px) {
    .main-content { padding: 24px 20px; }
    .form-grid { grid-template-columns: 1fr; }
}

/* ══════════════════════════════════════════════════
   RESPONSIVE: MOBILE
══════════════════════════════════════════════════ */
@media (max-width: 768px) {
    /* Show topbar */
    .topbar { display: flex; }

    /* Show overlay */
    .sidebar-overlay { display: block; pointer-events: none; }
    .sidebar-overlay.active { pointer-events: auto; }

    /* Hide sidebar by default */
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }

    /* Main content below topbar */
    .main-content { margin-left: 0; padding: 16px; margin-top: var(--topbar-h); max-width: 100vw; overflow-x: visible; }

    /* Stats */
    .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
    .stat-value { font-size: 24px; }

    /* Page header */
    .page-header { flex-direction: column; align-items: stretch; }
    .page-header h1 { font-size: 18px; }
    .page-header > .btn { align-self: flex-start; }

    /* Toolbar */
    .toolbar { flex-direction: column; align-items: stretch; }
    .toolbar-left, .toolbar-right { width: 100%; }
    .toolbar-left form { width: 100%; display: flex; gap: 8px; }
    .toolbar-left form input { flex: 1; max-width: 100% !important; }

    /* Forms */
    .form-grid { grid-template-columns: 1fr; }
    .card { padding: 14px; }

    /* Dashboard */
    .dashboard-grid { grid-template-columns: 1fr; }

    /* Modal: full bottom sheet */
    .modal-backdrop {
        padding: 0;
        align-items: flex-end;
    }
    .modal {
        border-radius: 20px 20px 0 0;
        max-height: 92vh;
        max-width: 100%;
        width: 100%;
        animation: slideUp 0.25s ease;
    }
    @keyframes slideUp {
        from { transform: translateY(100%); }
        to   { transform: translateY(0); }
    }
    .modal-header {
        padding: 16px 16px 12px;
        position: sticky; top: 0;
        background: white; z-index: 1;
        border-radius: 20px 20px 0 0;
    }
    .modal-footer {
        padding: 12px 16px 24px;
        position: sticky; bottom: 0;
        background: white; z-index: 1;
        flex-direction: column;
    }
    .modal-footer .btn { width: 100%; justify-content: center; }
    .modal-body { padding: 14px 16px; }
}

@media (max-width: 400px) {
    .stats-grid { grid-template-columns: 1fr; }
}


/* ============================================================
   FIX MOBILE: clicks + product cards
   ============================================================ */
.sidebar-overlay { pointer-events: none; }
.sidebar-overlay.active { pointer-events: auto; }
.sidebar { z-index: 150; }
.topbar { z-index: 200; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; touch-action: pan-x; }

@media (max-width: 768px) {
    .productos-table thead { display: none; }
    .productos-table, .productos-table tbody, .productos-table tr, .productos-table td {
        display: block; width: 100%; min-width: 0;
    }
    .productos-table { min-width: 0; }
    .productos-table tr {
        background: #fff; border: 1px solid var(--border); border-radius: 14px;
        padding: 12px; margin-bottom: 12px; box-shadow: var(--shadow-sm); cursor: pointer;
    }
    .productos-table td { border: none; padding: 6px 0; }
    .productos-table td::before {
        content: attr(data-label); display: block; font-size: 11px; font-weight: 700;
        color: var(--muted); margin-bottom: 2px; text-transform: uppercase;
    }
    .productos-table td:first-child::before { display: none; }
    .productos-table td img, .productos-table td div[style*="width:44px"] {
        width: 64px !important; height: 64px !important;
    }
    .productos-table td:last-child > div { display: flex; gap: 8px; }
    .productos-table td:last-child .btn { flex: 1; justify-content: center; }
}
