/* ==========================================================================
   Hotspot Admin · Estilos (CSS puro moderno, dark mode, responsive)
   ========================================================================== */
:root {
    --bg:        #0d1117;
    --bg-soft:   #161b22;
    --bg-card:   #1c2230;
    --bg-input:  #0b0f16;
    --border:    #2b3240;
    --border-2:  #3a4252;
    --text:      #e6edf3;
    --text-dim:  #8b949e;
    --accent:    #4f8cff;
    --accent-2:  #2d6fe0;
    --ok:        #3fb950;
    --ok-bg:     rgba(63,185,80,.13);
    --err:       #f85149;
    --err-bg:    rgba(248,81,73,.13);
    --warn:      #d29922;
    --radius:    12px;
    --radius-sm: 8px;
    --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
    --sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--sans);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
button { font-family: inherit; }

/* ---------- Botones ---------- */
.btn {
    display: inline-flex; align-items: center; gap: 7px;
    background: var(--bg-soft); color: var(--text);
    border: 1px solid var(--border-2); border-radius: var(--radius-sm);
    padding: 9px 16px; font-size: .9rem; font-weight: 600;
    cursor: pointer; transition: all .12s ease; white-space: nowrap;
}
.btn:hover { border-color: var(--accent); transform: translateY(-1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn-primary { background: linear-gradient(180deg, var(--accent), var(--accent-2)); border-color: transparent; color: #fff; }
.btn-danger { color: var(--err); border-color: rgba(248,81,73,.4); }
.btn-danger:hover { border-color: var(--err); background: var(--err-bg); }
.btn-sm { padding: 6px 11px; font-size: .8rem; }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--bg-soft); transform: none; }

/* ---------- Login ---------- */
.login-wrap {
    min-height: 100vh; display: grid; place-items: center; padding: 20px;
    background: radial-gradient(900px 500px at 70% -10%, #1a2740 0%, var(--bg) 60%);
}
.login-card {
    width: 100%; max-width: 400px; background: var(--bg-card);
    border: 1px solid var(--border); border-radius: var(--radius);
    padding: 32px; box-shadow: 0 20px 60px rgba(0,0,0,.4);
}
.login-card h1 { margin: 0 0 4px; font-size: 1.5rem; display: flex; align-items: center; gap: 10px; }
.login-card .sub { color: var(--text-dim); margin: 0 0 24px; font-size: .9rem; }

/* ---------- Formularios ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field label { font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text-dim); font-weight: 600; }
.field input, .field select, .field textarea {
    background: var(--bg-input); border: 1px solid var(--border);
    border-radius: var(--radius-sm); padding: 10px 12px; color: var(--text);
    font-size: .9rem; font-family: var(--sans); outline: none; transition: border-color .15s ease; width: 100%;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent); }
.field input[type="color"] { height: 42px; padding: 4px; cursor: pointer; }
.field .hint { font-size: .76rem; color: var(--text-dim); }
.field .err-msg { font-size: .76rem; color: var(--err); }
.check-row { display: flex; align-items: center; gap: 9px; margin-bottom: 14px; }
.check-row input { width: 17px; height: 17px; accent-color: var(--accent); }
.check-row label { font-size: .88rem; color: var(--text); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0 16px; }

/* ---------- Layout app (sidebar + contenido) ---------- */
.layout { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.sidebar {
    background: var(--bg-soft); border-right: 1px solid var(--border);
    display: flex; flex-direction: column; padding: 20px 14px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.15rem; padding: 6px 10px 20px; }
.nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav a {
    display: flex; align-items: center; gap: 11px; padding: 10px 12px;
    border-radius: var(--radius-sm); color: var(--text-dim); font-weight: 500; font-size: .92rem;
}
.nav a:hover { background: var(--bg-card); color: var(--text); }
.nav a.active { background: var(--bg-card); color: var(--text); box-shadow: inset 3px 0 0 var(--accent); }
.nav a .ico { width: 18px; text-align: center; }
.sidebar-foot { border-top: 1px solid var(--border); padding-top: 14px; margin-top: 10px; }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 6px 10px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: linear-gradient(135deg, var(--accent), var(--accent-2)); display: grid; place-items: center; font-weight: 700; color: #fff; }
.user-meta { overflow: hidden; }
.user-meta .nm { font-size: .85rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-meta .rl { font-size: .72rem; color: var(--text-dim); }

.content { padding: 28px 32px; overflow: auto; }
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; gap: 16px; flex-wrap: wrap; }
.page-head h2 { margin: 0; font-size: 1.5rem; letter-spacing: -.02em; }
.page-head .desc { color: var(--text-dim); font-size: .9rem; margin-top: 2px; }

/* ---------- Tarjetas / tablas ---------- */
.card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.card + .card { margin-top: 20px; }
.card-pad { padding: 22px; }
.card-title { font-size: 1rem; font-weight: 600; margin: 0 0 16px; }

table { width: 100%; border-collapse: collapse; }
thead th {
    text-align: left; font-size: .72rem; text-transform: uppercase; letter-spacing: .07em;
    color: var(--text-dim); padding: 13px 16px; border-bottom: 1px solid var(--border); background: var(--bg-soft);
}
tbody td { padding: 13px 16px; border-bottom: 1px solid var(--border); font-size: .9rem; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: rgba(255,255,255,.02); }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }

.badge { display: inline-flex; align-items: center; gap: 6px; font-size: .74rem; font-weight: 600; font-family: var(--mono); padding: 3px 10px; border-radius: 999px; }
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge.ok { color: var(--ok); background: var(--ok-bg); }
.badge.off { color: var(--text-dim); background: rgba(139,148,158,.12); }
.badge.err { color: var(--err); background: var(--err-bg); }
.tag { font-size: .72rem; font-weight: 600; padding: 3px 9px; border-radius: 6px; background: var(--bg-soft); border: 1px solid var(--border-2); color: var(--text-dim); }
.tag.super { color: #d6a4ff; border-color: rgba(214,164,255,.35); }
.tag.operator { color: var(--accent); border-color: rgba(79,140,255,.35); }
.tag.viewer { color: var(--text-dim); }

/* ---------- Modal ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: grid; place-items: center; padding: 20px; z-index: 50; }
.modal { background: var(--bg-card); border: 1px solid var(--border-2); border-radius: var(--radius); width: 100%; max-width: 560px; max-height: 90vh; overflow: auto; box-shadow: 0 24px 70px rgba(0,0,0,.5); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.modal-head h3 { margin: 0; font-size: 1.1rem; }
.modal-body { padding: 22px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 22px; border-top: 1px solid var(--border); }

/* ---------- Toasts ---------- */
.toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 10px; z-index: 100; }
.toast { background: var(--bg-card); border: 1px solid var(--border-2); border-left: 3px solid var(--accent); border-radius: var(--radius-sm); padding: 12px 16px; min-width: 240px; max-width: 360px; box-shadow: 0 10px 30px rgba(0,0,0,.4); animation: slideIn .2s ease; font-size: .88rem; }
.toast.ok { border-left-color: var(--ok); }
.toast.err { border-left-color: var(--err); }
@keyframes slideIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: none; } }

/* ---------- Utilidades ---------- */
.empty { text-align: center; color: var(--text-dim); padding: 40px 20px; }
.spinner { width: 20px; height: 20px; border: 2px solid var(--border-2); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; }
.center-load { display: grid; place-items: center; padding: 60px; }
@keyframes spin { to { transform: rotate(360deg); } }
.mono { font-family: var(--mono); font-size: .82rem; }
.muted { color: var(--text-dim); }
.flex { display: flex; align-items: center; gap: 10px; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.mt-16 { margin-top: 16px; } .mb-0 { margin-bottom: 0; }
.section-label { font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-dim); font-weight: 700; margin: 22px 0 12px; }

/* ---------- Tarjetas de métricas (dashboard) ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 8px; }
.stat-card { display: flex; align-items: center; gap: 14px; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; }
.stat-ico { font-size: 1.6rem; width: 46px; height: 46px; display: grid; place-items: center; background: var(--bg-soft); border-radius: 12px; flex-shrink: 0; }
.stat-value { font-size: 1.7rem; font-weight: 800; letter-spacing: -.02em; line-height: 1; }
.stat-label { font-size: .82rem; color: var(--text-dim); margin-top: 4px; }
@media (max-width: 880px) { .stat-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 480px) { .stat-grid { grid-template-columns: 1fr; } }

/* ---------- Pestañas (tabs) ---------- */
.tabs { display: inline-flex; gap: 4px; background: var(--bg-soft); border: 1px solid var(--border); border-radius: 10px; padding: 4px; margin-bottom: 20px; }
.tab { display: inline-flex; align-items: center; gap: 7px; padding: 8px 16px; border: none; background: transparent; color: var(--text-dim); font-weight: 600; font-size: .88rem; border-radius: 7px; cursor: pointer; transition: all .12s; }
.tab:hover { color: var(--text); }
.tab.active { background: var(--bg-card); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.3); }

/* ---------- Editor de portal (2 columnas) ---------- */
.portal-layout { display: grid; grid-template-columns: 1fr 360px; gap: 22px; align-items: start; }
.portal-preview-col { position: sticky; top: 20px; }

/* Plantillas de color */
.template-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.tpl-card { border: 2px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; cursor: pointer; transition: all .12s; background: var(--bg-soft); }
.tpl-card:hover { border-color: var(--border-2); transform: translateY(-2px); }
.tpl-card.active { border-color: var(--accent); }
.tpl-grad { height: 56px; display: grid; place-items: center; color: #fff; }
.tpl-foot { padding: 8px 10px; }
.tpl-foot .nm { font-size: .78rem; font-weight: 600; margin-bottom: 5px; }
.tpl-dots { display: flex; gap: 5px; }
.tpl-dots span { width: 11px; height: 11px; border-radius: 50%; border: 1px solid rgba(255,255,255,.2); }

/* Dropzone de logo */
.logo-row { display: flex; align-items: center; gap: 16px; }
.logo-box { width: 92px; height: 92px; border: 2px dashed var(--border-2); border-radius: var(--radius-sm); display: grid; place-items: center; background: var(--bg-input); overflow: hidden; flex-shrink: 0; }
.logo-box img { width: 100%; height: 100%; object-fit: contain; }
.logo-box .ph { color: var(--text-dim); font-size: 1.6rem; }

/* Color picker combinado */
.color-field { display: flex; align-items: center; gap: 8px; }
.color-field input[type="color"] { width: 44px; height: 40px; padding: 3px; flex-shrink: 0; }
.color-field input[type="text"] { font-family: var(--mono); text-transform: uppercase; }

/* ---------- Vista previa: teléfono ---------- */
.preview-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.preview-head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; font-weight: 600; }
.preview-sub { color: var(--text-dim); font-size: .8rem; margin-bottom: 14px; }
.preview-tabs { display: flex; gap: 4px; background: var(--bg-soft); border-radius: 8px; padding: 3px; margin-bottom: 16px; }
.preview-tabs button { flex: 1; padding: 6px 4px; border: none; background: transparent; color: var(--text-dim); font-size: .72rem; font-weight: 600; border-radius: 6px; cursor: pointer; }
.preview-tabs button.active { background: var(--bg-card); color: var(--text); }

.phone { width: 240px; margin: 0 auto; border-radius: 30px; padding: 9px; background: #0a0a0a; box-shadow: 0 16px 40px rgba(0,0,0,.45); border: 1px solid #2a2a2a; }
.phone-screen { border-radius: 22px; overflow: hidden; height: 440px; position: relative; }
.phone-status { display: flex; align-items: center; justify-content: space-between; padding: 7px 16px 4px; font-size: 10px; font-weight: 700; }
.phone-content { padding: 14px 16px; height: calc(100% - 26px); overflow: auto; }
.pv-hero { border-radius: 16px; padding: 20px 16px; text-align: center; color: #fff; position: relative; overflow: hidden; }
.pv-logo { width: 52px; height: 52px; border-radius: 14px; background: rgba(255,255,255,.18); display: grid; place-items: center; margin: 0 auto 12px; font-size: 1.5rem; overflow: hidden; }
.pv-logo img { width: 100%; height: 100%; object-fit: contain; }
.pv-title { font-weight: 700; font-size: 15px; }
.pv-msg { font-size: 11px; opacity: .85; margin-top: 4px; }
.pv-card { border-radius: 14px; margin-top: 12px; padding: 14px; }
.pv-input { height: 34px; border-radius: 9px; margin-top: 8px; display: flex; align-items: center; padding: 0 10px; font-size: 11px; }
.pv-btn { height: 36px; border-radius: 9px; margin-top: 12px; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 12px; }
.pv-otp { display: flex; gap: 7px; justify-content: center; margin: 14px 0; }
.pv-otp div { width: 30px; height: 38px; border-radius: 8px; display: grid; place-items: center; font-weight: 700; font-size: 15px; }
.pv-success-ico { width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; margin: 4px auto 12px; font-size: 1.7rem; color: #fff; }
.pv-terms { display: flex; gap: 7px; align-items: flex-start; font-size: 10px; margin-top: 10px; padding: 8px; border-radius: 8px; }
.pv-check { width: 14px; height: 14px; border-radius: 4px; flex-shrink: 0; display: grid; place-items: center; font-size: 9px; color: #fff; }

/* ---------- Responsive ---------- */
@media (max-width: 1000px) { .portal-layout { grid-template-columns: 1fr; } .portal-preview-col { position: static; } }
@media (max-width: 560px) { .template-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 820px) {
    .layout { grid-template-columns: 1fr; }
    .sidebar { flex-direction: row; align-items: center; padding: 10px 14px; overflow-x: auto; }
    .brand { padding: 6px 10px; }
    .nav { flex-direction: row; }
    .sidebar-foot { border-top: none; border-left: 1px solid var(--border); padding: 0 0 0 12px; margin: 0 0 0 auto; }
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
    .content { padding: 20px 16px; }
    .user-meta { display: none; }
}
