/* Affiliate Studio AI · estilos de la interfaz */
:root {
    --afs-primary: #5b5bd6;
    --afs-primary-600: #4b4bc4;
    --afs-bg: #f5f6fb;
    --afs-surface: #ffffff;
    --afs-border: #e7e8f0;
    --afs-text: #1e2235;
    --afs-muted: #6b7085;
    --afs-sidebar: #13152a;
    --afs-sidebar-text: #a9adc6;
    --afs-radius: 14px;
    --sidebar-w: 248px;
    --bs-primary: #5b5bd6;
    --bs-primary-rgb: 91, 91, 214;
    --bs-link-color: #5b5bd6;
    --bs-link-color-rgb: 91, 91, 214;
    --bs-body-font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
body { background: var(--afs-bg); color: var(--afs-text); font-size: .925rem; }
.btn-primary { --bs-btn-bg: var(--afs-primary); --bs-btn-border-color: var(--afs-primary); --bs-btn-hover-bg: var(--afs-primary-600); --bs-btn-hover-border-color: var(--afs-primary-600); --bs-btn-active-bg: var(--afs-primary-600); --bs-btn-disabled-bg: #a3a3e8; --bs-btn-disabled-border-color: #a3a3e8; }
.btn-outline-primary { --bs-btn-color: var(--afs-primary); --bs-btn-border-color: var(--afs-primary); --bs-btn-hover-bg: var(--afs-primary); --bs-btn-hover-border-color: var(--afs-primary); }
.form-control:focus, .form-select:focus { border-color: #a5a5ee; box-shadow: 0 0 0 .2rem rgba(91, 91, 214, .15); }
.form-check-input:checked { background-color: var(--afs-primary); border-color: var(--afs-primary); }
.btn { border-radius: 10px; }
.form-control, .form-select { border-radius: 10px; }
code { color: #8a3ab9; }

/* Sidebar */
.sidebar { position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); background: var(--afs-sidebar); color: var(--afs-sidebar-text); display: flex; flex-direction: column; z-index: 1040; transition: transform .2s ease; }
.sidebar-brand { display: flex; align-items: center; gap: .65rem; padding: 1.15rem 1.25rem; color: #fff; text-decoration: none; font-weight: 600; letter-spacing: -.01em; }
.sidebar-brand b { color: #8f8ffa; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: .25rem .75rem 1rem; }
.nav-section { font-size: .68rem; text-transform: uppercase; letter-spacing: .08em; color: #5f6382; padding: 1rem .75rem .4rem; }
.nav-item { display: flex; align-items: center; gap: .7rem; padding: .55rem .75rem; border-radius: 10px; color: var(--afs-sidebar-text); text-decoration: none; margin-bottom: 2px; }
.nav-item i { font-size: 1.05rem; width: 1.1rem; text-align: center; }
.nav-item:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.nav-item.active { background: linear-gradient(90deg, rgba(109, 93, 252, .35), rgba(109, 93, 252, .12)); color: #fff; }
.nav-item.disabled { opacity: .45; cursor: not-allowed; }
.nav-item em { margin-left: auto; font-style: normal; font-size: .62rem; text-transform: uppercase; background: rgba(255, 255, 255, .08); padding: .1rem .4rem; border-radius: 6px; }
.sidebar-foot { padding: .9rem 1.25rem; color: #5f6382; border-top: 1px solid rgba(255, 255, 255, .06); }
.sidebar-backdrop { display: none; }

/* Main */
.main { margin-left: var(--sidebar-w); min-height: 100vh; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 1020; display: flex; align-items: center; gap: .75rem; height: 64px; padding: 0 1.5rem; background: rgba(245, 246, 251, .85); backdrop-filter: blur(8px); border-bottom: 1px solid var(--afs-border); }
.topbar-title { font-size: 1.15rem; font-weight: 600; margin: 0; }
.btn-icon { font-size: 1.4rem; padding: .2rem .5rem; }
.user-chip { display: flex; align-items: center; gap: .5rem; background: var(--afs-surface); border: 1px solid var(--afs-border); border-radius: 999px; padding: .25rem .75rem .25rem .25rem; }
.avatar { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: linear-gradient(135deg, #6d5dfc, #2fb3ff); color: #fff; font-weight: 600; font-size: .85rem; }
.content { padding: 1.5rem; flex: 1; }

@media (max-width: 991.98px) {
    .sidebar { transform: translateX(-100%); }
    body.sidebar-open .sidebar { transform: none; }
    body.sidebar-open .sidebar-backdrop { display: block; position: fixed; inset: 0; background: rgba(10, 12, 25, .45); z-index: 1030; }
    .main { margin-left: 0; }
    .content { padding: 1rem; }
}

/* Cards */
.panel { border: 1px solid var(--afs-border); border-radius: var(--afs-radius); box-shadow: 0 1px 2px rgba(20, 22, 50, .04); }
.panel > .card-header { background: transparent; border-bottom: 1px solid var(--afs-border); font-weight: 600; padding: .9rem 1.25rem; }
.panel .table { --bs-table-bg: transparent; }
.panel .table th { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--afs-muted); font-weight: 600; border-bottom-color: var(--afs-border); }
.panel .table td, .panel .table th { padding-left: 1.25rem; padding-right: 1.25rem; }

/* KPI */
.kpi-card { background: var(--afs-surface); border: 1px solid var(--afs-border); border-radius: var(--afs-radius); padding: 1rem 1.1rem; height: 100%; }
.kpi-icon { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; font-size: 1.15rem; margin-bottom: .75rem; }
.kpi-value { font-size: 1.65rem; font-weight: 700; line-height: 1.1; letter-spacing: -.02em; min-height: 1.9rem; }
.kpi-label { color: var(--afs-muted); font-size: .8rem; }
.tone-indigo .kpi-icon { background: #ececff; color: #5b5bd6; }
.tone-violet .kpi-icon { background: #f3e8ff; color: #9333ea; }
.tone-amber .kpi-icon { background: #fff4db; color: #c27c0e; }
.tone-green .kpi-icon { background: #e3f8ec; color: #15924c; }
.tone-sky .kpi-icon { background: #e1f3fe; color: #0b84c6; }
.tone-rose .kpi-icon { background: #ffe7ee; color: #d0315f; }

/* Gráfico de barras CSS */
.bar-chart { display: flex; align-items: flex-end; gap: 6px; height: 180px; padding-top: 1.25rem; }
.bar-chart .bar { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; }
.bar-chart .bar-fill { width: 100%; max-width: 34px; border-radius: 6px 6px 2px 2px; background: linear-gradient(180deg, #8b7dff, #5b5bd6); min-height: 3px; position: relative; transition: height .35s ease; }
.bar-chart .bar-fill span { position: absolute; top: -1.2rem; left: 50%; transform: translateX(-50%); font-size: .68rem; color: var(--afs-muted); }
.bar-chart .bar-label { font-size: .65rem; color: var(--afs-muted); margin-top: .35rem; white-space: nowrap; }
.gs-value { font-size: 1.25rem; font-weight: 700; }
.gs-label { font-size: .75rem; color: var(--afs-muted); }

.status-dot { width: 9px; height: 9px; border-radius: 50%; background: #c4c7d6; display: inline-block; }
.ok .status-dot, .status-dot.ok { background: #22c55e; box-shadow: 0 0 0 3px rgba(34, 197, 94, .18); }
.status-dot.bad { background: #ef4444; }
.status-dot.warn { background: #f59e0b; }
.worker-tile { border: 1px solid var(--afs-border); border-radius: 12px; padding: .8rem; height: 100%; }
.cron-item { border: 1px solid var(--afs-border); border-radius: 12px; padding: .8rem; margin-bottom: .6rem; background: #fbfbfe; }

/* Auth */
.auth-body { background: radial-gradient(circle at 20% 10%, #e8e6ff 0, transparent 45%), radial-gradient(circle at 90% 90%, #dff3ff 0, transparent 40%), var(--afs-bg); }
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.auth-card { width: 100%; max-width: 410px; border: 1px solid var(--afs-border); border-radius: 18px; box-shadow: 0 20px 50px rgba(30, 34, 80, .08); }

/* Installer */
.install-body { background: radial-gradient(circle at 15% 0, #e8e6ff 0, transparent 40%), var(--afs-bg); }
.install-wrap { max-width: 860px; margin: 0 auto; padding: 2rem 1rem 3rem; }
.install-brand { display: flex; gap: .75rem; align-items: center; margin-bottom: 1.5rem; }
.install-card { border: 1px solid var(--afs-border); border-radius: 18px; box-shadow: 0 20px 50px rgba(30, 34, 80, .06); }
.install-steps { list-style: none; display: flex; gap: .4rem; padding: 0; margin: 0 0 1.25rem; flex-wrap: wrap; }
.install-steps li { display: flex; align-items: center; gap: .4rem; font-size: .8rem; color: var(--afs-muted); background: #fff; border: 1px solid var(--afs-border); border-radius: 999px; padding: .25rem .75rem .25rem .3rem; }
.install-steps .dot { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: #eef0f6; font-size: .72rem; font-weight: 600; }
.install-steps li.current { color: var(--afs-text); border-color: #c7c7f3; }
.install-steps li.current .dot { background: var(--afs-primary); color: #fff; }
.install-steps li.done .dot { background: #22c55e; color: #fff; }
.check-list .list-group-item { border-color: var(--afs-border); }
.status-tile { display: flex; gap: .75rem; align-items: flex-start; border: 1px solid var(--afs-border); border-radius: 12px; padding: .9rem; }
.status-tile i { font-size: 1.3rem; }
.status-tile.ok i { color: #16a34a; }
.status-tile.bad i { color: #dc2626; }
.help-box { background: #f8f8fd; border: 1px dashed #d6d7e6; border-radius: 12px; padding: .75rem 1rem; }
.help-box summary { cursor: pointer; font-weight: 500; }
.summary-list dt { font-weight: 500; color: var(--afs-muted); }
.done-icon { width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; margin: 0 auto; background: #dcfce7; color: #16a34a; font-size: 2rem; }

/* Toasts */
.toast-container { z-index: 1090; }
.toast { border: 0; border-radius: 12px; box-shadow: 0 10px 30px rgba(20, 22, 50, .15); }

/* Biblioteca */
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 1rem; }
.media-card { display: block; background: var(--afs-surface); border: 1px solid var(--afs-border); border-radius: var(--afs-radius); overflow: hidden; color: inherit; text-decoration: none; transition: box-shadow .15s, transform .15s; }
.media-card:hover { box-shadow: 0 8px 24px rgba(20, 22, 50, .08); transform: translateY(-2px); color: inherit; }
.media-thumb { position: relative; aspect-ratio: 9 / 12; background: #0f1020; display: grid; place-items: center; overflow: hidden; }
.media-thumb img { width: 100%; height: 100%; object-fit: cover; }
.media-thumb-empty { color: #6b7085; font-size: 2rem; }
.media-duration { position: absolute; right: 6px; bottom: 6px; background: rgba(0, 0, 0, .7); color: #fff; font-size: .72rem; padding: .1rem .4rem; border-radius: 6px; }
.media-flag { position: absolute; left: 6px; top: 6px; background: rgba(255, 255, 255, .92); color: #333; font-size: .68rem; padding: .1rem .45rem; border-radius: 6px; font-weight: 600; }
.media-flag.clean { background: #5b5bd6; color: #fff; }
.media-body { padding: .65rem .75rem; }
.media-name { font-weight: 600; font-size: .85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.media-meta { display: flex; justify-content: space-between; gap: .5rem; font-size: .72rem; color: var(--afs-muted); margin-top: .15rem; }
.dropzone { border: 2px dashed #cfd1e3; border-radius: 14px; padding: 1.75rem 1rem; text-align: center; cursor: pointer; color: var(--afs-muted); background: #fafaff; transition: border-color .15s, background .15s; }
.dropzone:hover, .dropzone.over { border-color: var(--afs-primary); background: #f2f2ff; }
.dropzone.has-file { border-style: solid; border-color: #22c55e; color: var(--afs-text); background: #f3fdf6; }
.player { max-height: 70vh; background: #000; }

/* Limpieza */
.frame-strip { display: flex; gap: .5rem; overflow-x: auto; padding-bottom: .25rem; }
.frame-thumb { flex: 0 0 auto; width: 74px; border: 2px solid transparent; border-radius: 8px; padding: 0; background: none; position: relative; overflow: hidden; }
.frame-thumb img { width: 100%; display: block; aspect-ratio: 9 / 16; object-fit: cover; }
.frame-thumb span { position: absolute; bottom: 0; left: 0; right: 0; background: rgba(0, 0, 0, .65); color: #fff; font-size: .65rem; }
.frame-thumb.active { border-color: var(--afs-primary); }
.frame-stage { position: relative; display: inline-block; max-width: 100%; line-height: 0; background: #000; border-radius: 10px; overflow: hidden; }
.frame-stage img { max-width: 100%; max-height: 62vh; user-select: none; -webkit-user-drag: none; }
.frame-stage canvas { position: absolute; inset: 0; cursor: crosshair; touch-action: none; }
.region-row { display: flex; gap: .6rem; align-items: center; padding: .65rem 1rem; border-bottom: 1px solid var(--afs-border); }
.region-dot { width: 24px; height: 24px; border-radius: 50%; color: #fff; font-size: .75rem; font-weight: 700; display: grid; place-items: center; flex: 0 0 auto; }
