/* =====================================================
   Psico-Lab Theme System (Brand + Dark Mode Ready)
===================================================== */

:root {

    /* Tipografía */
    --font-main: system-ui, sans-serif;

    /* Light mode */
    --color-bg: #f4f6f8;
    --color-card: white;
    --color-text: #111;

    /* Radar */
    --color-critical: #ff4d4d;
    --color-warning: #ffaa00;
    --color-ok: #33cc66;

    /* Branding */
    --color-primary: #4a6cff;

    /* UI neutrals */
    --color-border: #e5e7eb;
    --color-table-head: #f0f3f7;

    /* Design system interior (PsicoLab) */
    --color-navy: #172C51;
    --color-red: #C00000;
    --color-orange: #FF7611;
    --color-text-secondary: #6B6560;
    --color-text-muted: #8FA5BF;
    --color-border-blue: #D6E2F0;
    --color-bg-soft: #F4F8FD;
}

/* =====================================================
   Cognitive / IRT UI blocks (Bloque 1)
===================================================== */

@keyframes pulse-dot {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(0.85); }
}
.motor-dot {
    width: 8px;
    height: 8px;
    background: #2E7D32;
    border-radius: 50%;
    animation: pulse-dot 2s ease-in-out infinite;
    flex-shrink: 0;
}

.intel-card {
    background: var(--color-card);
    border: 0.5px solid var(--color-border);
    border-left: 3px solid var(--color-navy);
    border-radius: 0 8px 8px 0;
    padding: 14px 16px;
}
.intel-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: nowrap;
}
.intel-card-header[role="button"] {
    cursor: pointer;
    user-select: none;
}
.intel-campaign-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--color-navy);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}
.intel-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}
.dot-ready { background: #2E7D32; }
.dot-progress { background: var(--color-orange); }
.dot-starting { background: var(--color-border-blue); }

.priority-badge {
    font-size: 10px;
    font-weight: 500;
    padding: 3px 10px;
    border-radius: 20px;
    white-space: nowrap;
}
.priority-high { background: #FFF0F0; color: var(--color-red); }
.priority-medium { background: #FEF3EB; color: var(--color-orange); }
.priority-low { background: #EEF3FA; color: var(--color-navy); }

.progress-track {
    width: 100%;
    height: 6px;
    background: var(--color-bg);
    border-radius: 3px;
    overflow: hidden;
}
.progress-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.6s ease;
}
.fill-low { background: var(--color-red); }
.fill-mid { background: var(--color-orange); }
.fill-high { background: var(--color-navy); }

.alert-chip {
    font-size: 10px;
    padding: 3px 8px;
    border-radius: 4px;
    border-left: 2px solid;
}
.alert-low { background: #FFF8F0; border-color: var(--color-orange); color: #7A4000; }
.alert-medium { background: #FFF0F0; border-color: var(--color-red); color: #6B0000; }
.alert-info { background: #EEF3FA; border-color: var(--color-navy); color: var(--color-navy); }

.action-btn {
    font-size: 11px;
    font-weight: 500;
    padding: 5px 12px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.action-primary { background: var(--color-navy); color: #fff; }
.action-secondary { background: #EEF3FA; color: var(--color-navy); border: 0.5px solid var(--color-border-blue); }
.action-warning { background: #FEF3EB; color: var(--color-orange); }
.action-chip { font-size: 10px; color: var(--color-text-muted); padding: 3px 8px; background: var(--color-bg); border-radius: 4px; }

/* Compact mode: collapsed by default, expands on click */
.intel-card .intel-card-body { display: none; }
.intel-card.expanded .intel-card-body { display: block; }
.intel-click-hint {
    font-size: 10px;
    color: var(--color-text-muted);
    padding: 2px 6px;
    border-radius: 999px;
    background: var(--color-bg);
    border: 0.5px solid var(--color-border-blue);
}
.intel-card.expanded .intel-chevron { transform: rotate(180deg); }


/* -----------------------------------------------------
   Dark Mode automático
----------------------------------------------------- */

@media (prefers-color-scheme: dark) {

    :root {

        --color-bg: #111418;
        --color-card: #1a1f25;
        --color-text: #e6edf3;

        --color-critical: #ff6b6b;
        --color-warning: #ffcc66;
        --color-ok: #66ff99;

        --color-primary: #7aa2ff;

        --color-border: #2a2f36;
        --color-table-head: #1f242b;
    }

}


/* =====================================================
   Base layout (responsive)
===================================================== */

body {

    margin: 0;
    padding: 1rem;
    font-family: var(--font-main);
    background: var(--color-bg);
    color: var(--color-text);
    box-sizing: border-box;

}

*,
*::before,
*::after {

    box-sizing: inherit;

}

@media (min-width: 768px) {

    body { padding: 1.5rem 2rem; }

}

@media (min-width: 1024px) {

    body { padding: 2rem 40px; max-width: 1400px; margin-left: auto; margin-right: auto; }

}


/* =====================================================
   Cards / Panels
===================================================== */

.panel {

    background: var(--color-card);
    padding: 24px;
    border-radius: 8px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.05);

}


/* =====================================================
   Tables
===================================================== */

table {

    border-collapse: collapse;
    width: 100%;
    background: var(--color-card);

}

th {

    background: var(--color-table-head);
    padding: 10px;
    text-align: left;

}

td {

    padding: 10px;

}

tr {

    border-bottom: 1px solid var(--color-border);

}


/* =====================================================
   Buttons
===================================================== */

button {

    background: #f0f0f0 !important;
    color: #111 !important;
    border: 1px solid #ccc;
    padding: 8px 14px;
    border-radius: 6px;
    cursor: pointer;

}

button:hover {

    background: #e6e6e6 !important;

}

/* botón principal */

.btn-primary {

    background: var(--color-primary) !important;
    color: white !important;
    border: none;

}

.btn-primary:hover {

    opacity: 0.9;

}

/* =====================================================
   Links
===================================================== */

a {

    color: var(--color-primary);
    text-decoration: none;

}

a:hover {

    text-decoration: underline;

}


/* =====================================================
   Responsive: tablas, contenedores, utilidades
===================================================== */

/* Tablas: scroll horizontal en móvil */
.table-wrap {

    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 1rem;

}

.table-wrap table {

    min-width: 500px;

}

/* Contenedor ancho controlado */
.container {

    width: 100%;
    max-width: 1200px;
    margin-left: auto;
    margin-right: auto;
    padding-left: 1rem;
    padding-right: 1rem;

}

/* Cards/paneles que no se estiren de más en móvil */
.panel {

    max-width: 100%;
    overflow-x: hidden;

}

/* Inputs y controles más grandes en táctil */
@media (max-width: 767px) {

    input[type="text"],
    input[type="email"],
    input[type="number"],
    input[type="password"],
    select {

        min-height: 44px;
        font-size: 16px; /* evita zoom en iOS */
        padding: 10px 12px;

    }

}

/* Espaciado responsive */
@media (max-width: 640px) {

    .panel { padding: 1rem; }
    h1 { font-size: 1.5rem; }
    h2 { font-size: 1.25rem; }

}

/* =====================================================
   Interior / Design system (dashboard, cards, pills)
===================================================== */

.btn-secondary {
    background: #EEF3FA;
    color: var(--color-navy);
    border: 0.5px solid var(--color-border-blue);
    border-radius: 7px;
    font-size: 0.85rem;
    padding: 8px 12px;
    cursor: pointer;
}
.btn-secondary:hover {
    background: var(--color-navy);
    color: #fff;
}

.card {
    background: var(--color-card);
    border: 0.5px solid #E8EFF6;
    border-left: 3px solid var(--color-navy);
    border-radius: 0 8px 8px 0;
    padding: 16px 18px;
    margin-bottom: 16px;
}

.test-card {
    background: var(--color-card);
    border: 0.5px solid #E8EFF6;
    border-left: 3px solid var(--color-navy);
    border-radius: 0 8px 8px 0;
    padding: 12px 14px;
    margin-bottom: 12px;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

/* Mismo estilo que test-card para la sección Campañas recientes */
.campaign-card {
    background: var(--color-card);
    border: 0.5px solid #E8EFF6;
    border-left: 3px solid var(--color-navy);
    border-radius: 0 8px 8px 0;
    padding: 14px 16px;
    margin-bottom: 12px;
}

/* Botones alineados con Biblioteca de tests (no azul primario) */
.btn-card {
    color: #172C51;
    background: #EEF3FA;
    border: 0.5px solid #D6E2F0;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.85rem;
    cursor: pointer;
    text-decoration: none;
}
.btn-card:hover {
    background: var(--color-navy);
    color: #fff;
    border-color: var(--color-navy);
}

.pill-filter {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    border-radius: 999px;
    border: 0.5px solid var(--color-border-blue);
    background: var(--color-card);
    color: #5A7A99;
    font-size: 0.8rem;
    cursor: pointer;
    margin-right: 6px;
}
.pill-filter.active {
    background: var(--color-navy);
    color: #fff;
    border-color: var(--color-navy);
}

.upload-zone {
    background: #F4F8FD;
    border: 1px dashed #B8CDE0;
    border-radius: 8px;
    padding: 20px 24px;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    justify-content: space-between;
    font-size: 0.9rem;
    color: #5A7A99;
}
.upload-zone input[type="file"] {
    position: absolute;
    width: 0.1px;
    height: 0.1px;
    opacity: 0;
    overflow: hidden;
    z-index: -1;
}
.upload-zone .upload-trigger {
    background: transparent;
    color: #172C51;
    border: 0.5px solid #D6E2F0;
    padding: 8px 14px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
}
.upload-zone .upload-trigger:hover {
    background: #172C51;
    color: #fff;
    border-color: #172C51;
}
.search-input-page {
    background: #F4F8FD;
    border: 0.5px solid #D6E2F0;
    border-radius: 6px;
    padding: 8px 12px;
    font-size: 0.9rem;
    min-width: 260px;
}

.dashboard-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.25rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}
.dashboard-header-left {
    display: flex;
    align-items: center;
    gap: 0.8rem;
}
.dashboard-logo {
    max-height: 40px;
    width: auto;
    object-fit: contain;
}
.dashboard-title {
    font-size: 1.4rem;
    font-weight: 500;
    color: var(--color-text);
}
.dashboard-subtitle {
    font-size: 0.85rem;
    color: var(--color-text-secondary);
}

.progress-bar {
    height: 8px;
    background: #E5E7EB;
    border-radius: 6px;
    overflow: hidden;
    margin-top: 6px;
}
.progress-fill {
    height: 8px;
    background: linear-gradient(90deg, #ea580c, #f97316);
}

.section {
    margin-bottom: 40px;
}
.library-title,
.section-label {
    font-size: 11px;
    font-weight: 600;
    color: #8FA5BF;
    margin: 0 0 12px 0;
    text-transform: uppercase;
    letter-spacing: 0.8px;
}

.radar-panel {
    display: flex;
    flex-wrap: wrap;
    gap: 40px;
}
.status { font-weight: 500; margin-top: 6px; font-size: 0.9rem; }
.status-risk { color: #d32f2f; }
.status-attention { color: #f57c00; }
.status-stable { color: #2e7d32; }

@media (max-width: 640px) {
    .radar-panel { flex-direction: column; }
}

/* =====================================================
   Layout interior: nav + sidebar + main
===================================================== */

.layout-wrap {
    display: flex;
    min-height: 100vh;
    flex-direction: column;
}
.layout-body {
    display: flex;
    flex: 1;
    min-height: 0;
    position: relative;
}
.layout-main {
    flex: 1;
    min-width: 0;
    overflow-y: auto;
    background: #F7F6F4;
    padding: 24px 28px 40px;
}
.layout-body.has-sidebar .layout-main {
    padding-left: 32px;
}
body.sidebar-collapsed .layout-body.has-sidebar .layout-main {
    padding-left: 32px;
}

/* Nav superior */
.nav-top {
    background: #FFFFFF;
    border-bottom: 2px solid #C00000;
    padding: 10px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
}
.nav-top-left {
    display: flex;
    align-items: center;
    gap: 12px;
}
.nav-logo-peaks {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: flex-end;
    gap: 2px;
}
.nav-logo-peaks span {
    width: 6px;
    background: #C00000;
    border-radius: 1px;
}
.nav-logo-peaks span:nth-child(1) { height: 10px; }
.nav-logo-peaks span:nth-child(2) { height: 16px; background: #172C51; }
.nav-logo-peaks span:nth-child(3) { height: 22px; background: #FF7611; }
.nav-logo-text {
    font-size: 1.1rem;
    font-weight: 600;
    color: #172C51;
    letter-spacing: -0.02em;
}
/* Marca en barra superior: mismo tamaño para PsicoLab por defecto y logos de org (compacto, alineado con nav ~50px) */
.nav-brand-logo {
    height: 28px;
    max-height: 28px;
    width: auto;
    max-width: 132px;
    object-fit: contain;
    object-position: left center;
    display: block;
    flex-shrink: 0;
}
.nav-org-avatar {
    width: 28px;
    height: 28px;
    min-width: 28px;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.02em;
    color: #FFFFFF;
    background: linear-gradient(145deg, #5C0A24 0%, #C00000 45%, #8B1538 100%);
    border: 0.5px solid rgba(192, 0, 0, 0.45);
    flex-shrink: 0;
    line-height: 1;
}
.nav-pills {
    display: flex;
    align-items: center;
    gap: 4px;
}
.nav-pills a {
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.9rem;
    color: #172C51;
    text-decoration: none;
}
.nav-pills a:hover {
    background: #EEF3FA;
}
.nav-org-badge {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.8rem;
    color: #5A7A99;
    background: #EDEBE8;
}
.nav-exit {
    font-size: 0.9rem;
    color: #5A7A99;
    text-decoration: none;
}
.nav-exit:hover { text-decoration: underline; }

/* Botón menú hamburguesa: oculto en desktop */
.nav-toggle {
    display: none;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 1px solid #D6E2F0;
    background: #fff;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1.4rem;
    line-height: 1;
    color: #172C51;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.nav-toggle:hover {
    background: #EEF3FA;
}
.nav-toggle:focus {
    outline: 2px solid #172C51;
    outline-offset: 2px;
}

/* En escritorio el menú hamburguesa no se muestra: solo enlaces visibles */
@media (min-width: 769px) {
    .nav-toggle {
        display: none !important;
    }
}

/* Sidebar colapsable */
#sidebar {
    width: 168px;
    min-width: 168px;
    flex-shrink: 0;
    background: #EEF3FA;
    border-right: 0.5px solid #D6E2F0;
    padding: 16px 0;
    overflow: hidden;
    position: relative;
    transition: width 0.25s ease, min-width 0.25s ease;
}
#sidebar.collapsed {
    width: 0;
    min-width: 0;
}
body.sidebar-collapsed #sidebar-toggle {
    left: 0;
}
#sidebar-toggle {
    position: absolute;
    left: 168px;
    top: 50%;
    transform: translateY(-50%);
    transition: left 0.25s ease, background 0.2s, color 0.2s;
    width: 24px;
    min-width: 24px;
    height: 48px;
    padding: 0;
    background: #D6E2F0;
    border: none;
    border-left: 1px solid #B8CDE0;
    border-radius: 0 6px 6px 0;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    color: #5A7A99;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 1px 0 4px rgba(0,0,0,0.08);
}
#sidebar-toggle:hover {
    background: #B8CDE0;
    color: #172C51;
}
.sidebar-label {
    font-size: 9px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: #8FA5BF;
    padding: 12px 14px 4px;
}
#sidebar .sb-item {
    display: block;
    padding: 8px 14px;
    font-size: 12px;
    color: #5A7A99;
    text-decoration: none;
    border-left: 2.5px solid transparent;
    border-radius: 0 6px 6px 0;
}
#sidebar .sb-item:hover {
    color: #172C51;
    background: rgba(255,255,255,0.6);
}
#sidebar .sb-item.active {
    background: #ffffff;
    color: #172C51;
    font-weight: 500;
    border-left: 2.5px solid #C00000;
}
.sidebar-dot {
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    margin-right: 6px;
    vertical-align: 0.15em;
}
.sidebar-dot.red { background: #C00000; }
.sidebar-dot.orange { background: #FF7611; }
.sidebar-dot.gray { background: #8FA5BF; }
.sidebar-dot.blue { background: #172C51; }

/* Contenido del dashboard (flujo normal dentro de layout-main) */
.dashboard-content {
    position: relative;
    width: 100%;
}

/* Page header (dentro de layout-main) */
.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    position: static;
}
.page-title {
    font-size: 22px;
    font-weight: 500;
    color: #172C51;
    margin: 0 0 4px 0;
}
.page-title-line {
    width: 28px;
    height: 2px;
    background: #C00000;
    border-radius: 1px;
    margin-top: 8px;
}
.page-subtitle {
    font-size: 0.8rem;
    color: #8FA5BF;
    margin: 0;
}
.page-header-actions {
    flex-shrink: 0;
}

/* Stat cards (fila de 3) */
.stat-cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}
.stat-card {
    background: #F4F8FD;
    border: 0.5px solid #D6E2F0;
    border-top: 2px solid #172C51;
    border-radius: 0 0 8px 8px;
    padding: 14px 16px;
}
.stat-card.emphasis {
    border-top-color: #C00000;
}
.stat-card-value {
    font-size: 1.5rem;
    font-weight: 600;
    color: #172C51;
}
.stat-card-label {
    font-size: 0.8rem;
    color: #8FA5BF;
    margin-top: 2px;
}

/* Test card con badge de tipo */
.test-card-360 {
    border-left-color: #FF7611;
}
.badge-type {
    display: inline-block;
    font-size: 10px;
    font-weight: 500;
    padding: 2px 8px;
    border-radius: 20px;
    margin-bottom: 4px;
}
.badge-type.psico { background: #EEF3FA; color: #172C51; }
.badge-type.encuesta { background: #FEF3EB; color: #C05000; }
.badge-type.360 { background: #FFF0F0; color: #C00000; }
.badge-type.exam { background: #E8EFF6; color: #172C51; }

@media (max-width: 900px) {
    .stat-cards { grid-template-columns: 1fr; }
    #sidebar { width: 140px; min-width: 140px; }
    #sidebar.collapsed { width: 0; min-width: 0; }
    #sidebar-toggle { left: 140px; }
    body.sidebar-collapsed #sidebar-toggle { left: 0; }
}
/* Móvil: menú hamburguesa en la barra superior */
@media (max-width: 768px) {
    .nav-toggle {
        display: inline-flex !important;
    }
    .nav-top {
        padding: 10px 16px;
    }
    .nav-header .nav-top-left {
        flex-wrap: wrap;
        flex: 1;
        min-width: 0;
        gap: 8px;
    }
    .nav-header .nav-pills,
    .nav-header .nav-org-badge {
        display: none !important;
        width: 100%;
        flex-basis: 100%;
        margin-top: 8px;
        padding-top: 8px;
        border-top: 1px solid #D6E2F0;
    }
    .nav-header.nav-open .nav-pills {
        display: flex !important;
        flex-direction: column;
        align-items: stretch;
    }
    .nav-header.nav-open .nav-pills a {
        padding: 10px 12px;
        border-radius: 6px;
    }
    .nav-header.nav-open .nav-org-badge {
        display: block !important;
        width: 100%;
        margin-top: 6px;
        padding: 8px 12px;
        border-radius: 6px;
        border: 1px solid #D6E2F0;
        background: #fff;
        font-size: 0.9rem;
    }
}

@media (max-width: 768px) {
    .layout-body { flex-direction: column; }
    #sidebar { width: 100%; min-width: 100%; display: flex; flex-wrap: wrap; gap: 4px; padding: 12px; border-right: none; border-bottom: 0.5px solid #D6E2F0; }
    #sidebar.collapsed { width: 0; min-width: 0; overflow: hidden; display: none; }
    #sidebar-toggle { left: 0; top: auto; bottom: 12px; transform: none; }
    .sidebar-label { width: 100%; padding: 4px 8px; }
    #sidebar .sb-item { display: inline-block; padding: 6px 10px; border-radius: 6px; }
    .layout-body.has-sidebar .layout-main { padding-left: 16px; padding-right: 16px; padding-top: 16px; padding-bottom: 24px; }
    .page-header { flex-direction: column; align-items: flex-start; gap: 12px; }
    .page-title { font-size: 1.35rem; }
    .stat-cards { gap: 12px; }
    .upload-zone { flex-direction: column; align-items: stretch; text-align: left; }
    .upload-zone .upload-trigger { align-self: flex-start; }
    .section-label { margin-bottom: 10px; }
    .test-card { flex-direction: column; align-items: flex-start; gap: 10px; }
    .search-input-page { width: 100%; min-width: 0; box-sizing: border-box; }
    .pill-filter { margin-bottom: 4px; }
}

@media (max-width: 480px) {
    .nav-top { padding: 8px 12px; }
    .nav-logo-text { font-size: 1rem; }
    .layout-main { padding: 12px 12px 24px !important; }
    .layout-body.has-sidebar .layout-main { padding-left: 12px !important; padding-right: 12px !important; }
    .page-title { font-size: 1.2rem; }
    .stat-card { padding: 12px; }
}