/* ============================================================
   Marquia Radar — sistema de diseño
   Basado en la paleta/estilo de NEXO (dashboard de reclutamiento
   de Marquia). Sin dependencias externas (fuentes del sistema,
   sin CDN) para mantener la imagen liviana, en línea con el
   resto del proyecto (ver README_deployment.md).
   ============================================================ */

:root {
    --nexo-indigo:        #4636e3;
    --nexo-indigo-dark:   #362ab8;
    --nexo-indigo-darker: #241c86;
    --nexo-indigo-soft:   #ece9fc;

    --nexo-bg:            #cbd6ec;
    --nexo-surface:       #ffffff;
    --nexo-surface-muted: #e7ebf7;
    --nexo-border:        #d7deef;

    --nexo-text:          #14161f;
    --nexo-text-muted:    #6b7280;
    --nexo-text-soft:     #9aa3b5;

    --nexo-green-bg:    #dff5e8;
    --nexo-green-text:  #0f7a4c;
    --nexo-purple-bg:   #ece9fc;
    --nexo-purple-text: #5b4fd6;
    --nexo-red-bg:      #fbe3e3;
    --nexo-red-text:    #c33636;
    --nexo-amber-bg:    #fff4d6;
    --nexo-amber-text:  #8a6100;
    --nexo-orange:      #f2994a;

    --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --font-mono: ui-monospace, "Cascadia Mono", "Segoe UI Mono", Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: var(--font-sans);
    color: var(--nexo-text);
    background: var(--nexo-bg);
}

a { color: inherit; }

.link-muted {
    color: var(--nexo-indigo);
    font-size: 13px;
    text-decoration: none;
    transition: color 0.15s ease;
}
.link-muted:hover { text-decoration: underline; color: var(--nexo-indigo-dark); }

/* --- Botones --- */
.btn {
    display: inline-block;
    border: none;
    border-radius: 8px;
    padding: 13px 24px;
    font-size: 16px;
    line-height: 1.2;
    font-weight: 600;
    font-family: var(--font-sans);
    cursor: pointer;
    text-decoration: none;
    text-align: center;
    transition: transform 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease, filter 0.15s ease;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 4px 10px rgba(0, 0, 0, 0.14); }
.btn:active { transform: translateY(0); box-shadow: none; }
.btn-sm { padding: 11px 20px; font-size: 15px; line-height: 1.2; border-radius: 7px; }
.btn-block { display: block; width: 100%; }
.btn-primary { background: var(--nexo-indigo); color: #fff; }
.btn-primary:hover { background: var(--nexo-indigo-dark); }
.btn-success { background: var(--nexo-green-text); color: #fff; }
.btn-success:hover { filter: brightness(0.9); }
.btn-muted { background: var(--nexo-surface-muted); color: var(--nexo-text); }
.btn-muted:hover { background: var(--nexo-border); }
.btn-danger { background: var(--nexo-red-text); color: #fff; }
.btn-danger:hover { filter: brightness(0.9); }

/* --- Inputs --- */
.field-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin: 16px 0 6px;
}
/* Fila label + "Limpiar" para los <select multiple> — con multiple no hay
   forma de deseleccionar todo con el mouse (hay que ctrl+click cada
   opción), así que se agrega un botón explícito. */
.field-label-row { display: flex; justify-content: space-between; align-items: baseline; margin: 16px 0 6px; }
.field-label-row .field-label { margin: 0; }
.btn-limpiar-select { font-size: 12px; }
.field-hint {
    font-size: 12px;
    color: var(--nexo-text-muted);
    margin-top: 4px;
}
.input, select.input {
    width: 100%;
    padding: 10px 12px;
    font-size: 14px;
    font-family: var(--font-sans);
    border: 1px solid var(--nexo-border);
    background: var(--nexo-surface-muted);
    border-radius: 8px;
    color: var(--nexo-text);
}
.input:focus, select.input:focus {
    outline: 2px solid var(--nexo-indigo);
    outline-offset: 1px;
    background: var(--nexo-surface);
}

/* --- Badges --- */
.badge {
    display: inline-block;
    font-size: 14px;
    font-weight: 600;
    padding: 6px 16px;
    border-radius: 999px;
    margin: 10px 0 6px;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.badge:hover {
    transform: translateY(-1px) scale(1.05);
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.14);
}
.badge-purple { background: var(--nexo-purple-bg); color: var(--nexo-purple-text); }
.badge-green  { background: var(--nexo-green-bg);  color: var(--nexo-green-text); }
.badge-red    { background: var(--nexo-red-bg);    color: var(--nexo-red-text); }
.badge-gray   { background: var(--nexo-surface-muted); color: var(--nexo-text-muted); }
.badge-amber  { background: var(--nexo-amber-bg);   color: var(--nexo-amber-text); }

/* --- Alertas --- */
.alert-error {
    background: var(--nexo-red-bg);
    color: var(--nexo-red-text);
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 13px;
    margin: 14px 0;
}
.alert-ok {
    background: var(--nexo-green-bg);
    color: var(--nexo-green-text);
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 13px;
    margin: 14px 0;
}

/* ============================================================
   Pantalla de login — split screen (hero indigo + panel claro)
   ============================================================ */
.auth-body { background: var(--nexo-bg); }

.auth-split {
    display: flex;
    min-height: 100vh;
}

.auth-hero {
    position: relative;
    overflow: hidden;
    flex: 1 1 55%;
    background: linear-gradient(160deg, var(--nexo-indigo) 0%, var(--nexo-indigo-darker) 100%);
    color: #fff;
    padding: 48px 56px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}
.auth-hero-dots {
    position: absolute;
    inset: 0;
    background-image: radial-gradient(rgba(255,255,255,0.18) 1px, transparent 1px);
    background-size: 22px 22px;
    opacity: 0.5;
}
.auth-hero-circle {
    position: absolute;
    top: -80px;
    right: -60px;
    width: 340px;
    height: 340px;
    border-radius: 50%;
    border: 1px solid rgba(255,255,255,0.25);
}
.auth-hero-dot-accent {
    position: absolute;
    top: 116px;
    right: 118px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--nexo-orange);
}
.auth-hero-top, .auth-hero-mid, .auth-hero-steps {
    position: relative;
    z-index: 1;
}
.brand {
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 15px;
    letter-spacing: 0.06em;
}
.brand-sub {
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 0.08em;
    opacity: 0.75;
    margin-top: 4px;
}
.auth-hero-mid h1 {
    font-size: 34px;
    line-height: 1.2;
    margin: 0 0 14px;
    max-width: 480px;
}
.auth-hero-mid p {
    font-size: 15px;
    opacity: 0.85;
    max-width: 420px;
    line-height: 1.5;
}
.auth-hero-steps { display: flex; flex-direction: column; gap: 14px; }
.step { display: flex; gap: 12px; align-items: flex-start; }
.step-n {
    font-family: var(--font-mono);
    font-size: 12px;
    border: 1px solid rgba(255,255,255,0.35);
    border-radius: 6px;
    padding: 2px 7px;
    height: fit-content;
}
.step strong { font-size: 14px; }
.step-d { font-size: 12px; opacity: 0.75; margin-top: 2px; }

.auth-panel {
    flex: 1 1 45%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--nexo-bg);
    padding: 32px;
}
.auth-form-wrap { width: 100%; max-width: 340px; }
.brand-dark { color: var(--nexo-indigo); }
.auth-form-wrap h2 { font-size: 24px; margin: 10px 0 2px; }
.auth-sub { font-size: 13px; color: var(--nexo-text-muted); margin: 0 0 6px; }
.auth-footer {
    text-align: center;
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--nexo-text-soft);
    letter-spacing: 0.04em;
    margin-top: 22px;
}

@media (max-width: 860px) {
    .auth-split { flex-direction: column; }
    .auth-hero { padding: 32px 28px; }
    .auth-hero-mid h1 { font-size: 26px; }
}

/* ============================================================
   Shell de la app (sidebar + contenido)
   ============================================================ */
.app-body { background: var(--nexo-bg); }

.shell {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 230px;
    flex-shrink: 0;
    background: var(--nexo-surface);
    border-right: 1px solid var(--nexo-border);
    padding: 20px 16px;
    display: flex;
    flex-direction: column;
    /* Pegada al viewport: no se estira con el largo de la lista de
       oportunidades, así no hay que scrollear la página entera para ver
       "Cerrar sesión" cuando hay muchos posts cargados. */
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}
.sidebar-top { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; }
.logo-box {
    width: 34px; height: 34px;
    background: var(--nexo-indigo);
    color: #fff;
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700;
    flex-shrink: 0;
}
.brand-sm { font-weight: 700; font-size: 14px; color: var(--nexo-indigo); }
.brand-sm-sub { font-family: var(--font-mono); font-size: 10px; color: var(--nexo-text-muted); letter-spacing: 0.05em; }

.nav-section {
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: 0.08em;
    color: var(--nexo-text-soft);
    margin: 6px 4px 8px;
}
/* Nombre de la empresa arriba del nav — más grande que un label genérico
   de sección, es la identidad de a quién le pertenecen estos datos. */
.sidebar-empresa {
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: var(--nexo-indigo);
    margin: 6px 4px 10px;
}
.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-item {
    display: block;
    padding: 9px 12px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    color: var(--nexo-text-muted);
    text-decoration: none;
    transition: background-color 0.15s ease, color 0.15s ease, transform 0.15s ease;
}
.nav-item:hover { background: var(--nexo-surface-muted); color: var(--nexo-text); transform: translateX(2px); }
.nav-item.active { background: var(--nexo-indigo-soft); color: var(--nexo-indigo); font-weight: 600; }
.nav-item.active:hover { background: var(--nexo-indigo-soft); transform: none; }

.sidebar-bottom { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--nexo-border); }
.account-pill {
    display: block;
    background: var(--nexo-indigo);
    color: #fff;
    text-align: center;
    padding: 9px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 13px;
    margin-bottom: 8px;
    text-decoration: none;
    transition: background-color 0.15s ease, transform 0.15s ease;
}
.account-pill:hover { background: var(--nexo-indigo-dark); transform: translateY(-1px); }
.account-email { font-size: 12px; color: var(--nexo-text-muted); word-break: break-all; margin-bottom: 6px; }
.account-role { font-size: 11px; color: var(--nexo-text-soft); margin-bottom: 6px; text-transform: capitalize; }
/* Los <a class="link-muted"> del sidebar-bottom (Cambiar contraseña / Cerrar
   sesión) son inline por defecto — sin esto quedan uno al lado del otro en
   vez de apilados. */
.sidebar-bottom .link-muted { display: block; margin-bottom: 6px; }
.sidebar-bottom .link-muted:last-child { margin-bottom: 0; }

.content {
    flex: 1;
    padding: 32px 40px;
    max-width: 1500px;
}
.impersonando-banner {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--nexo-amber-bg);
    color: var(--nexo-amber-text);
    font-size: 13px;
    font-weight: 600;
    padding: 10px 16px;
    border-radius: 10px;
    margin-bottom: 18px;
}
.impersonando-banner .btn { margin-left: auto; }

.content-header { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 18px; flex-wrap: wrap; gap: 10px; }
.content-header h1 { font-size: 22px; margin: 0; }
.content-sub { font-size: 13px; color: var(--nexo-text-muted); margin: 4px 0 0; }

/* --- Tabs (filtros) --- */
.tabs { margin-bottom: 18px; display: flex; gap: 8px; flex-wrap: wrap; }
.tab {
    display: inline-block;
    padding: 6px 14px;
    border-radius: 999px;
    text-decoration: none;
    color: var(--nexo-text-muted);
    background: var(--nexo-surface);
    border: 1px solid var(--nexo-border);
    font-size: 13px;
    transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}
.tab:hover { background: var(--nexo-indigo-soft); color: var(--nexo-indigo); border-color: var(--nexo-indigo-soft); transform: translateY(-1px); }
.tab.active { background: var(--nexo-indigo); color: #fff; border-color: var(--nexo-indigo); }
.tab.active:hover { background: var(--nexo-indigo-dark); border-color: var(--nexo-indigo-dark); }

/* --- Cards de oportunidades --- */
.card {
    background: var(--nexo-surface);
    border: 1px solid var(--nexo-border);
    border-radius: 12px;
    padding: 18px;
    margin-bottom: 12px;
}
.card-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.autor { font-weight: 700; font-size: 17px; }
.autor-link { color: inherit; text-decoration: none; }
.autor-link:hover { color: var(--nexo-indigo); text-decoration: underline; }
.headline { color: var(--nexo-text-muted); font-size: 14px; margin-top: 3px; }
.fecha { font-size: 12px; color: var(--nexo-text-soft); white-space: nowrap; }
.contenido { font-size: 14px; margin: 4px 0 10px; white-space: pre-wrap; line-height: 1.5; }
.contenido-completo { display: block; margin-top: 6px; }
.btn-leer-mas {
    display: inline-block;
    margin-top: 4px;
    font-weight: 600;
}
button.link-muted {
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    font-family: inherit;
}

.contacto {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 20px;
    font-size: 13px;
    background: var(--nexo-amber-bg);
    color: var(--nexo-amber-text);
    padding: 8px 10px;
    border-radius: 8px;
    margin: 8px 0;
}
.contacto-item { display: inline-flex; align-items: center; gap: 4px; }

/* --- Tarjeta de perfil (perfiles.php) --- */
.perfil-ubicacion { font-size: 13px; color: var(--nexo-text-muted); margin-top: 2px; }
.perfil-metricas { display: flex; gap: 14px; font-size: 12px; color: var(--nexo-text-soft); margin-top: 4px; }

/* --- Filtros avanzados (<details> nativo, sin JS) --- */
.filtros-avanzados { margin-top: 14px; }
.filtros-avanzados summary {
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    color: var(--nexo-indigo);
    padding: 6px 0;
}
.filtros-avanzados select[multiple] { padding: 6px; }
.filtros-avanzados textarea.input { resize: vertical; font-family: var(--font-sans); }
.btn-copiar {
    border: none;
    background: none;
    cursor: pointer;
    font-size: 12px;
    padding: 2px 4px;
    border-radius: 4px;
    line-height: 1;
}
.btn-copiar:hover { background: rgba(0, 0, 0, 0.08); }
.acciones { margin-top: 12px; display: flex; gap: 8px; flex-wrap: wrap; }
.empty { color: var(--nexo-text-muted); font-size: 14px; }

/* --- Agrupado por búsqueda ---
   Un panel grande de fondo por búsqueda: el título (grande, con checkbox
   para seleccionar todo el grupo y la cantidad de posts) va arriba, y las
   tarjetas quedan desplazadas a la derecha adentro del panel. */
.grupo-busqueda {
    background: var(--nexo-indigo-soft);
    border-radius: 18px;
    padding: 16px;
    margin-bottom: 28px;
}
.grupo-busqueda-cards {
    padding-left: 26px; /* desplaza el stack de tarjetas hacia la derecha */
}
.grupo-busqueda-cards .card:last-child { margin-bottom: 0; }
.grupo-busqueda-titulo {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--nexo-indigo);
    font-weight: 700;
    font-size: 16px;
    margin-bottom: 14px;
}
.grupo-busqueda-icono { font-size: 16px; }
.grupo-busqueda-cantidad {
    margin-left: auto;
    font-weight: 600;
    font-size: 13px;
    color: var(--nexo-indigo);
    background: var(--nexo-surface);
    padding: 4px 14px;
    border-radius: 999px;
    white-space: nowrap;
}

/* --- Usuarios --- */
.grid-2 { display: grid; grid-template-columns: minmax(260px, 340px) 1fr; gap: 20px; align-items: start; }
@media (max-width: 760px) { .grid-2 { grid-template-columns: 1fr; } }

.user-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--nexo-border);
    font-size: 13px;
    gap: 10px;
}
.user-row:last-child { border-bottom: none; }
.user-email { font-family: var(--font-mono); word-break: break-all; }
.user-actions { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }

/* --- Empresas (superadmin.php) --- */
.empresa-row { padding: 14px 0; border-bottom: 1px solid var(--nexo-border); }
.empresa-row:last-child { border-bottom: none; }
.empresa-row-header { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.empresa-key-form { display: flex; gap: 8px; margin-top: 10px; align-items: center; }
.empresa-key-form .input { font-family: var(--font-mono); font-size: 12px; }
.empresa-entrar-form { margin-top: 8px; }

/* --- Mostrar/ocultar Apify key --- */
.input-con-boton { display: flex; gap: 6px; align-items: center; flex: 1; }
.input-con-boton .input { flex: 1; }
.btn-toggle-key {
    flex-shrink: 0;
    width: 38px;
    height: 38px;
    border: 1px solid var(--nexo-border);
    border-radius: 8px;
    background: var(--nexo-surface);
    cursor: pointer;
    font-size: 15px;
    transition: background-color 0.15s ease;
}
.btn-toggle-key:hover { background: var(--nexo-surface-muted); }

/* --- Utilidad --- */
.hidden { display: none !important; }

/* --- Checkboxes de selección --- */
.check-wrap {
    display: flex;
    align-items: center;
    padding-right: 4px;
    padding-top: 2px;
}
.check-wrap input, .check-wrap-inline input {
    width: 16px;
    height: 16px;
    accent-color: var(--nexo-indigo);
    cursor: pointer;
}
.check-wrap-inline {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--nexo-text-muted);
    cursor: pointer;
}
.card-header { gap: 4px; }
.card-header-info { flex: 1; }
.avatar {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    background: var(--nexo-surface-muted);
}

/* --- Barra de acción masiva --- */
.bulk-bar {
    position: sticky;
    top: 12px;
    z-index: 5;
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    background: var(--nexo-indigo-darker);
    color: #fff;
    padding: 10px 16px;
    border-radius: 10px;
    margin-bottom: 14px;
    font-size: 13px;
}
.bulk-bar .check-wrap-inline { color: #fff; }

/* ============================================================
   Panel de scraping manual
   ============================================================ */
#panel-scraping { margin-bottom: 18px; }

/* --- Constructor de búsqueda booleana --- */
#operadores-busqueda { display: flex; flex-direction: column; gap: 8px; }
.operador-fila {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-top: 8px;
}
.operador-fila .operador-select { flex: 0 0 84px; }
.operador-fila .operador-input { flex: 1; }
.btn-quitar-operador {
    flex-shrink: 0;
    width: 34px;
    height: 34px;
    border: none;
    border-radius: 8px;
    background: var(--nexo-surface-muted);
    color: var(--nexo-text-muted);
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.15s ease, color 0.15s ease;
}
.btn-quitar-operador:hover { background: var(--nexo-red-bg); color: var(--nexo-red-text); }

.operadores-acciones {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 10px;
    flex-wrap: wrap;
}
#operadores-contador { margin: 0; }

.scraping-filtros {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}
@media (max-width: 640px) { .scraping-filtros { grid-template-columns: 1fr; } }

.scraping-form-acciones {
    display: flex;
    gap: 8px;
    margin-top: 18px;
}

.scraping-activo-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}
.scraping-activo-info { flex: 1; }
.scraping-activo-titulo { display: flex; align-items: center; gap: 8px; }
.scraping-activo-header strong { font-size: 14px; font-weight: 600; }
#scraping-contador { margin-top: 6px; }

/* margin-top (no margin-bottom en el header): así, cuando esta fila está
   oculta (scraping terminado, sin Pausar/Reanudar/Detener que mostrar),
   no deja ningún hueco/espacio residual abajo del panel. */
.scraping-controles { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
