/* ============================================================
   StreamHub — sistema de diseño
   Tipografía: Space Grotesk (display) + Inter (texto) + IBM Plex Mono (datos)
   Paleta: tinta casi negra + papel gris cálido + acento aqua señal
   ============================================================ */

:root {
    --ink: #14161b;
    --ink-soft: #4a4d57;
    --ink-faint: #8a8d97;
    --paper: #f6f6f4;
    --surface: #ffffff;
    --line: #e6e6e1;
    --line-soft: #eeeeea;

    --accent: #12b3a4;
    --accent-dark: #0a8d81;
    --accent-ink: #06423c;
    --accent-wash: #e6f6f4;

    --warn: #b5730b;
    --warn-wash: #fbf1de;
    --danger: #c1372a;
    --danger-wash: #faeae8;
    --success: #1f8a4c;
    --success-wash: #e8f5ec;
    --info: #3457c4;
    --info-wash: #e9edfb;

    --radius: 10px;
    --radius-sm: 7px;
    --shadow: 0 1px 2px rgba(20, 22, 27, 0.04), 0 8px 24px -12px rgba(20, 22, 27, 0.10);
    --font-display: 'Space Grotesk', 'Inter', sans-serif;
    --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'IBM Plex Mono', ui-monospace, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
    margin: 0;
    font-family: var(--font-body);
    background: var(--paper);
    color: var(--ink);
    font-size: 14.5px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 600; letter-spacing: -0.01em; margin: 0; }
a { color: inherit; }
button { font-family: inherit; }

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* ---------- Shell: sidebar + contenido ---------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
    width: 232px;
    flex-shrink: 0;
    background: var(--ink);
    color: #eceef1;
    display: flex;
    flex-direction: column;
    padding: 22px 14px;
    position: sticky;
    top: 0;
    height: 100vh;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 10px 22px 10px;
}
.brand-mark {
    width: 26px; height: 26px;
    display: flex; align-items: flex-end; gap: 2px;
    flex-shrink: 0;
}
.brand-mark span {
    width: 4px;
    background: var(--accent);
    border-radius: 2px;
    animation: barpulse 1.6s ease-in-out infinite;
}
.brand-mark span:nth-child(1) { height: 40%; animation-delay: 0s; }
.brand-mark span:nth-child(2) { height: 100%; animation-delay: .2s; }
.brand-mark span:nth-child(3) { height: 65%; animation-delay: .4s; }
.brand-mark span:nth-child(4) { height: 85%; animation-delay: .1s; }
@keyframes barpulse {
    0%, 100% { opacity: .55; transform: scaleY(.8); }
    50% { opacity: 1; transform: scaleY(1); }
}
@media (prefers-reduced-motion: reduce) {
    .brand-mark span { animation: none; opacity: 1; }
}
.sidebar-brand strong { font-family: var(--font-display); font-size: 16.5px; letter-spacing: -0.01em; }
.sidebar-brand small { display: block; color: #9aa0ab; font-size: 11px; }

.nav-group { margin-top: 6px; }
.nav-label {
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: #767c88;
    padding: 14px 12px 6px;
}
.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    color: #cfd2d9;
    text-decoration: none;
    font-size: 13.6px;
    font-weight: 500;
    margin-bottom: 2px;
    transition: background .12s ease, color .12s ease;
}
.nav-link svg { width: 17px; height: 17px; flex-shrink: 0; opacity: .85; }
.nav-link:hover { background: #ffffff12; color: #fff; }
.nav-link.active { background: var(--accent); color: #06231f; font-weight: 600; }
.nav-link.active svg { opacity: 1; }

.sidebar-footer {
    margin-top: auto;
    border-top: 1px solid #ffffff18;
    padding-top: 12px;
}
.sidebar-user {
    display: flex; align-items: center; gap: 9px;
    padding: 8px 10px; border-radius: var(--radius-sm);
}
.sidebar-user .avatar {
    width: 30px; height: 30px; border-radius: 50%;
    background: var(--accent-wash); color: var(--accent-ink);
    display: flex; align-items: center; justify-content: center;
    font-family: var(--font-display); font-weight: 700; font-size: 13px;
    flex-shrink: 0;
}
.sidebar-user .who { min-width: 0; }
.sidebar-user .who strong { display: block; font-size: 13px; color: #fff; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-user .who span { font-size: 11px; color: #9aa0ab; text-transform: capitalize; }
.logout-link {
    display: flex; align-items: center; gap: 8px;
    margin-top: 6px; padding: 8px 10px; font-size: 13px;
    color: #cfd2d9; text-decoration: none; border-radius: var(--radius-sm);
}
.logout-link:hover { background: #ffffff12; color: #fff; }

/* ---------- Contenido principal ---------- */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 20px 30px; border-bottom: 1px solid var(--line);
    background: var(--surface);
}
.topbar h1 { font-size: 19px; }
.topbar .subtitle { color: var(--ink-faint); font-size: 12.5px; margin-top: 2px; }
.content { padding: 26px 30px 60px; max-width: 1280px; width: 100%; }

/* ---------- Botones ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    border: 1px solid transparent; border-radius: var(--radius-sm);
    padding: 9px 16px; font-size: 13.5px; font-weight: 600;
    cursor: pointer; text-decoration: none; transition: transform .08s ease, opacity .12s ease, background .12s ease;
    line-height: 1.2;
}
.btn:active { transform: translateY(1px); }
.btn svg { width: 15px; height: 15px; }
.btn-primary { background: var(--ink); color: #fff; }
.btn-primary:hover { background: #292b32; }
.btn-accent { background: var(--accent); color: #06231f; }
.btn-accent:hover { background: var(--accent-dark); color: #fff; }
.btn-outline { background: transparent; border-color: var(--line); color: var(--ink); }
.btn-outline:hover { border-color: var(--ink-faint); background: var(--paper); }
.btn-ghost { background: transparent; color: var(--ink-soft); padding: 7px 10px; }
.btn-ghost:hover { background: var(--line-soft); }
.btn-danger { background: var(--danger-wash); color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-sm { padding: 6px 11px; font-size: 12.5px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- Tarjetas / KPIs ---------- */
.grid-kpi { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 24px; }
.kpi {
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 16px 18px;
}
.kpi .label { font-size: 12px; color: var(--ink-faint); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.kpi .value { font-family: var(--font-display); font-size: 27px; margin-top: 6px; }
.kpi .value small { font-size: 14px; color: var(--ink-faint); font-weight: 500; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.panel-head {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 16px 20px; border-bottom: 1px solid var(--line-soft); flex-wrap: wrap;
}
.panel-head h2 { font-size: 15.5px; }
.panel-body { padding: 18px 20px; }
.panel-toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.filter-row {
    display: flex; align-items: center; gap: 8px; flex-wrap: nowrap;
    padding: 12px 20px; border-bottom: 1px solid var(--line-soft);
    overflow-x: auto; -webkit-overflow-scrolling: touch;
}
.filter-row input, .filter-row select { flex: 0 0 auto; width: auto; }
.filter-row input#buscarCodigo { min-width: 170px; }
.filter-row select { min-width: 150px; }
.filter-row .btn { flex-shrink: 0; white-space: nowrap; }

.pagination-row {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 14px 20px; border-top: 1px solid var(--line-soft); flex-wrap: wrap;
}
.pagination-row span { font-size: 12.5px; }

/* ---------- Tablas ---------- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13.3px; }
table.data th {
    text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .04em;
    color: var(--ink-faint); font-weight: 600; padding: 10px 20px; border-bottom: 1px solid var(--line);
    white-space: nowrap;
}
table.data td { padding: 12px 20px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; white-space: nowrap; }
.cell-wrap { white-space: normal !important; min-width: 180px; }
table.data tbody tr:hover { background: var(--paper); }
table.data tbody tr:last-child td { border-bottom: none; }
.cell-mono { font-family: var(--font-mono); font-size: 12.5px; color: var(--ink-soft); }
.cell-strong { font-weight: 600; }
.cell-muted { color: var(--ink-faint); }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }

/* ---------- Badges de estado ---------- */
.badge {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 3px 10px; border-radius: 100px; font-size: 11.5px; font-weight: 600;
}
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-success { background: var(--success-wash); color: var(--success); }
.badge-warn { background: var(--warn-wash); color: var(--warn); }
.badge-danger { background: var(--danger-wash); color: var(--danger); }
.badge-info { background: var(--info-wash); color: var(--info); }
.badge-neutral { background: var(--line-soft); color: var(--ink-soft); }

/* ---------- Formularios ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.form-field { display: flex; flex-direction: column; gap: 6px; }
.form-field.full { grid-column: 1 / -1; }
.form-field label { font-size: 12.5px; font-weight: 600; color: var(--ink-soft); }
.form-field .hint { font-size: 11.5px; color: var(--ink-faint); }
input, select, textarea {
    font-family: inherit; font-size: 13.6px; color: var(--ink);
    border: 1px solid var(--line); border-radius: var(--radius-sm);
    padding: 9px 12px; background: var(--surface); width: 100%;
    transition: border-color .12s ease;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); outline: none; }
textarea { resize: vertical; min-height: 70px; font-family: inherit; }

/* ---------- Modal ---------- */
.modal-backdrop {
    position: fixed; inset: 0; background: rgba(20, 22, 27, 0.45);
    display: none; align-items: flex-start; justify-content: center;
    padding: 5vh 16px; z-index: 100; overflow-y: auto;
}
.modal-backdrop.open { display: flex; }
.modal {
    background: var(--surface); border-radius: 14px; width: 100%; max-width: 560px;
    box-shadow: 0 24px 60px -20px rgba(0,0,0,.35); animation: modalIn .14s ease;
}
@keyframes modalIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--line-soft); }
.modal-head h3 { font-size: 16px; }
.modal-close { background: none; border: none; cursor: pointer; color: var(--ink-faint); padding: 4px; border-radius: 6px; }
.modal-close:hover { background: var(--line-soft); color: var(--ink); }
.modal-body { padding: 20px 22px; max-height: 66vh; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 16px 22px; border-top: 1px solid var(--line-soft); }

/* ---------- Login / Registro ---------- */
.auth-shell {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    background: var(--ink); padding: 24px;
    background-image: radial-gradient(circle at 20% 20%, #ffffff08, transparent 40%), radial-gradient(circle at 80% 80%, #12b3a41a, transparent 45%);
}
.auth-card {
    background: var(--surface); border-radius: 16px; width: 100%; max-width: 400px;
    padding: 32px 30px; box-shadow: 0 30px 80px -30px rgba(0,0,0,.5);
}
.auth-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; }
.auth-brand strong { font-family: var(--font-display); font-size: 19px; }
.auth-card h1 { font-size: 20px; margin-bottom: 4px; }
.auth-card p.lead { color: var(--ink-faint); font-size: 13px; margin: 0 0 22px; }
.auth-foot { text-align: center; margin-top: 18px; font-size: 13px; color: var(--ink-faint); }
.auth-foot a { color: var(--accent-dark); font-weight: 600; text-decoration: none; }
.alert {
    padding: 10px 14px; border-radius: var(--radius-sm); font-size: 13px; margin-bottom: 16px;
    display: flex; align-items: center; gap: 8px;
}
.alert-danger { background: var(--danger-wash); color: var(--danger); }
.alert-success { background: var(--success-wash); color: var(--success); }
.alert-aviso { background: var(--warn-wash); color: #7a4a08; align-items: flex-start; line-height: 1.5; }
.alert-aviso svg { margin-top: 1px; color: var(--warn); }

/* ---------- Botón flotante de WhatsApp ---------- */
.wa-fab {
    position: fixed; right: 22px; bottom: 22px; z-index: 60;
    width: 56px; height: 56px; border-radius: 50%;
    background: #25D366; color: #fff;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 10px 28px -8px rgba(37, 211, 102, 0.55), 0 2px 8px rgba(0,0,0,.12);
    transition: transform .12s ease, box-shadow .12s ease;
}
.wa-fab:hover { transform: translateY(-2px) scale(1.04); box-shadow: 0 14px 34px -8px rgba(37, 211, 102, 0.65), 0 2px 8px rgba(0,0,0,.15); }
@media (max-width: 900px) {
    .wa-fab { right: 16px; bottom: 16px; width: 52px; height: 52px; }
}

/* ---------- Estado vacío ---------- */
.empty-state { text-align: center; padding: 50px 20px; color: var(--ink-faint); }
.empty-state svg { width: 40px; height: 40px; margin-bottom: 10px; opacity: .5; }
.empty-state p { margin: 4px 0 0; font-size: 13.5px; }

/* ---------- Catálogo (vista cliente) ---------- */
.catalog-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; }
.catalog-card {
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
    overflow: hidden; display: flex; flex-direction: column; transition: box-shadow .14s ease, transform .1s ease;
}
.catalog-card:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
.catalog-thumb {
    height: 108px; background: linear-gradient(135deg, var(--ink) 0%, #262932 100%);
    display: flex; align-items: center; justify-content: center;
    color: var(--accent); font-family: var(--font-display); font-weight: 700; font-size: 15px; letter-spacing: .02em;
}
.catalog-body { padding: 14px 16px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.catalog-body h3 { font-size: 14.5px; }
.catalog-body .svc { font-size: 11.5px; color: var(--ink-faint); text-transform: uppercase; letter-spacing: .04em; }
.catalog-body .desc { font-size: 12.5px; color: var(--ink-soft); flex: 1; }
.catalog-price { display: flex; align-items: baseline; justify-content: space-between; margin-top: 6px; }
.catalog-price .amount { font-family: var(--font-mono); font-size: 17px; font-weight: 600; }
.catalog-price .dur { font-size: 11.5px; color: var(--ink-faint); }

/* ---------- Utilidades ---------- */
.flex { display: flex; align-items: center; }
.gap-6 { gap: 6px; } .gap-8 { gap: 8px; } .gap-10 { gap: 10px; }
.text-right { text-align: right; }
.mt-16 { margin-top: 16px; }
.w-full { width: 100%; }
.toast-wrap { position: fixed; top: 18px; right: 18px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast {
    background: var(--ink); color: #fff; padding: 11px 16px; border-radius: var(--radius-sm);
    font-size: 13px; box-shadow: 0 10px 30px -10px rgba(0,0,0,.4); display: flex; align-items: center; gap: 8px;
    animation: toastIn .16s ease;
}
.toast.error { background: var(--danger); }
.toast.success { background: var(--success); }
@keyframes toastIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: translateY(0); } }

@media (max-width: 900px) {
    .form-grid { grid-template-columns: 1fr; }
    .sidebar {
        position: fixed; left: -260px; top: 0; z-index: 110;
        transition: left .2s ease; width: 250px; box-shadow: 0 0 40px rgba(0,0,0,.25);
    }
    .sidebar.open { left: 0; }
    .sidebar-close-btn {
        display: flex; align-items: center; justify-content: center;
        position: absolute; top: 14px; right: 12px;
        width: 30px; height: 30px; border-radius: 8px; border: none;
        background: #ffffff14; color: #cfd2d9; cursor: pointer; font-size: 15px;
    }
    .sidebar-close-btn:hover { background: #ffffff26; color: #fff; }
    .sidebar-overlay {
        display: none; position: fixed; inset: 0; background: rgba(20,22,27,.5); z-index: 105;
    }
    .sidebar-overlay.open { display: block; }
    .mobile-menu-btn {
        display: flex; align-items: center; justify-content: center;
        position: fixed; top: 14px; left: 14px; z-index: 90;
        width: 38px; height: 38px; border-radius: 9px; border: 1px solid var(--line);
        background: var(--surface); box-shadow: var(--shadow); color: var(--ink); cursor: pointer;
    }
    .mobile-menu-btn svg { width: 19px; height: 19px; }
    .topbar { padding: 16px 16px 16px 62px; }
    .content { padding: 20px 16px 50px; }
    .grid-kpi { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 901px) {
    .mobile-menu-btn, .sidebar-overlay, .sidebar-close-btn { display: none; }
}
