/* =============================================================
   mensajes.css — Vista Contacto / Mensajería
   Figma: Industria node 1-13501 (sincronizado 2026-03-10)
   ============================================================= */

/* ---------------------------------------------------------------
   1. LAYOUT PRINCIPAL — 3 paneles en fila
--------------------------------------------------------------- */

/* La main-wrapper ya aplica margin-left del sidebar.
   Sobreescribimos page-content para una vista de altura completa sin padding extra. */
.msgs-layout {
    display: flex;
    flex: 1;
    /* Ocupa exactamente el espacio entre el topbar mobile y el footer */
    height: calc(100vh - 56px - 48px);
    overflow: hidden;
    min-height: 0; /* Crucial para que los hijos flex puedan shrink */
}

@media (min-width: 768px) {
    .msgs-layout {
        height: calc(100vh - 48px);
    }
}

/* ---------------------------------------------------------------
   2. PANEL IZQUIERDO — Lista de contactos / hilos
--------------------------------------------------------------- */
.msgs-contacts {
    width: 280px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--color-border);
    background: #ffffff;
    overflow: hidden;
    /* En mobile: oculto por defecto, toggle con JS */
    transition: width var(--transition), transform var(--transition);
}

@media (max-width: 767px) {
    .msgs-contacts {
        position: fixed;
        z-index: 25;
        top: 56px;
        /* debajo del topbar */
        left: 0;
        height: calc(100vh - 56px);
        width: 280px;
        transform: translateX(-100%);
    }

    .msgs-contacts.is-open {
        transform: translateX(0);
    }
}

/* Cabecera del panel de contactos */
.msgs-contacts__header {
    padding: 16px;
    border-bottom: 1px solid var(--color-border);
    flex-shrink: 0;
}

.msgs-contacts__title {
    font-family: 'Lato', var(--font-base);
    font-size: 15px;
    font-weight: 700;
    color: var(--color-text);
    margin-bottom: 10px;
    line-height: 1.2;
}

/* Buscador */
.msgs-search {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #f3f4f6;
    border-radius: var(--radius-full);
    padding: 7px 12px;
}

.msgs-search__icon {
    width: 16px;
    height: 16px;
    color: #9ca3af;
    flex-shrink: 0;
}

.msgs-search__input {
    border: none;
    outline: none;
    background: transparent;
    font-size: 13px;
    font-family: var(--font-base);
    color: var(--color-text);
    width: 100%;
}

.msgs-search__input::placeholder {
    color: #adb5bd;
}

/* Lista de hilos */
.msgs-thread-list {
    flex: 1;
    overflow-y: auto;
    list-style: none;
    padding: 8px 0;
}

/* Hilo individual */
.msgs-thread {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 16px;
    cursor: pointer;
    border-left: 3px solid transparent;
    transition: background-color var(--transition), border-color var(--transition);
}

.msgs-thread:hover {
    background-color: #f9fafb;
}

.msgs-thread--active {
    background-color: #eff6ff;
    border-left-color: var(--color-brand);
}

.msgs-thread__avatar {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    object-fit: cover;
    flex-shrink: 0;
}

.msgs-thread__body {
    flex: 1;
    min-width: 0;
}

.msgs-thread__top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 4px;
    margin-bottom: 3px;
}

.msgs-thread__name {
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.msgs-thread__time {
    font-size: 11px;
    color: #9ca3af;
    white-space: nowrap;
    flex-shrink: 0;
}

.msgs-thread__preview {
    font-size: 12px;
    color: #6b7280;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 5px;
}

/* ── Status badges ────────────────────────────────────────── */
.status-badge {
    display: inline-block;
    font-size: 10px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    line-height: 1.6;
}

.status-badge--espera {
    background: #fef9c3;
    color: #92400e;
}

.status-badge--entrevista {
    background: #f3e5f5;
    color: #7b1fa2;
}

.status-badge--proceso {
    background: #dbeafe;
    color: #1e40af;
}

.status-badge--contratado {
    background: #d1fae5;
    color: #065f46;
}

.status-badge--rechazado {
    background: #fee2e2;
    color: #991b1b;
}

/* ---------------------------------------------------------------
   3. PANEL CENTRAL — Chat
--------------------------------------------------------------- */
.msgs-chat {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #f9fafb;
    overflow: hidden;
    min-width: 0;
    min-height: 0; /* Necesario para scroll correcto en flex */
}

/* Cabecera del chat */
.msgs-chat__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    background: #ffffff;
    border-bottom: 1px solid var(--color-border);
    flex-shrink: 0;
    gap: 12px;
}

.msgs-chat__contact {
    display: flex;
    align-items: center;
    gap: 10px;
}

.msgs-chat__avatar {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    object-fit: cover;
}

.msgs-chat__name {
    font-size: 14px;
    font-weight: 700;
    color: var(--color-text);
    display: block;
}

.msgs-chat__status {
    font-size: 11px;
    color: var(--color-success);
    display: block;
}

.msgs-chat__status::before {
    content: '●';
    font-size: 8px;
    margin-right: 4px;
}

.msgs-chat__ver-perfil {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    font-weight: 600;
    color: var(--color-accent);
    text-decoration: underline;
    text-underline-offset: 2px;
    transition: color var(--transition);
    white-space: nowrap;
    flex-shrink: 0;
}

.msgs-chat__ver-perfil:hover {
    color: var(--color-accent-light);
}

/* Área de mensajes (scrollable) */
.msgs-chat__messages {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 0; /* Esencial: permite que el flex item haga shrink y el scroll funcione */
    scroll-behavior: smooth;
}

/* Separador de fecha */
.msgs-date-sep {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 8px 0;
}

.msgs-date-sep::before,
.msgs-date-sep::after {
    content: '';
    flex: 1;
    height: 1px;
    background: #e5e7eb;
}

.msgs-date-sep span {
    font-size: 11px;
    color: #9ca3af;
    white-space: nowrap;
    padding: 0 4px;
}

/* Burbujas */
.msg {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    max-width: 75%;
}

.msg--received {
    align-self: flex-start;
}

.msg--sent {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.msg__avatar {
    width: 28px;
    height: 28px;
    border-radius: var(--radius-full);
    object-fit: cover;
    flex-shrink: 0;
    margin-bottom: 4px;
}

.msg__bubble {
    padding: 10px 14px;
    border-radius: 16px;
    position: relative;
    max-width: 100%;
}

.msg__bubble p {
    font-size: 13px;
    line-height: 1.5;
    color: var(--color-text);
    margin: 0;
}

.msg__bubble--received {
    background: #f3f4f6;
    border-bottom-left-radius: 4px;
}

.msg__bubble--sent {
    background: #dbeafe;
    border-bottom-right-radius: 4px;
}

.msg__bubble--sent p {
    color: #1e3a5f;
}

.msg__time {
    display: block;
    font-size: 10px;
    color: #9ca3af;
    margin-top: 4px;
    text-align: right;
}

.msg__bubble--received .msg__time {
    text-align: left;
}

/* Input de mensaje */
.msgs-input {
    display: flex;
    flex-direction: column;
    padding: 12px 16px;
    background: #ffffff;
    border-top: 1px solid var(--color-border);
    flex-shrink: 0;
    gap: 8px;
}

.msgs-input__box {
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: #f9fafb;
    padding: 10px 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.msgs-input__box:focus-within {
    border-color: var(--color-brand);
    box-shadow: 0 0 0 3px rgba(27, 78, 107, 0.08);
    background: #ffffff;
}

.msgs-input__field {
    border: none;
    outline: none;
    background: transparent;
    font-size: 13px;
    font-family: var(--font-base);
    color: var(--color-text);
    resize: none;
    min-height: 52px;
    max-height: 120px;
    line-height: 1.5;
    width: 100%;
}

.msgs-input__field::placeholder {
    color: #adb5bd;
}

.msgs-input__actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.msgs-input__attach {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--color-text-light);
    display: flex;
    align-items: center;
    padding: 4px;
    border-radius: var(--radius-sm);
    transition: color var(--transition);
}

.msgs-input__attach:hover {
    color: var(--color-brand);
}

.msgs-input__attach svg {
    width: 20px;
    height: 20px;
}

.msgs-input__footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.msgs-input__counter {
    font-size: 11px;
    color: #9ca3af;
    margin-left: auto;
}

.msgs-input__send {
    padding: 7px 20px;
    border-radius: var(--radius-full);
    background-color: var(--color-accent);
    color: #ffffff;
    border: none;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    font-family: var(--font-base);
    flex-shrink: 0;
    transition: background-color var(--transition), transform var(--transition);
}

.msgs-input__send:hover {
    background-color: var(--color-accent-light);
    transform: scale(1.02);
}

/* ---------------------------------------------------------------
   4. PANEL DERECHO — Contexto / vacante
--------------------------------------------------------------- */
.msgs-context {
    width: 300px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    background: #ffffff;
    border-left: 1px solid var(--color-border);
    overflow: hidden;
}

@media (max-width: 1100px) {
    .msgs-context {
        display: none;
    }
}

/* Tabs */
.msgs-tabs {
    display: flex;
    border-bottom: 1px solid var(--color-border);
    flex-shrink: 0;
}

.msgs-tab {
    flex: 1;
    padding: 12px 8px;
    font-size: 12px;
    font-weight: 500;
    font-family: var(--font-base);
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    color: #6b7280;
    transition: color var(--transition), border-color var(--transition);
    text-align: center;
    line-height: 1.3;
}

.msgs-tab:hover {
    color: var(--color-brand);
}

.msgs-tab--active {
    color: var(--color-brand);
    border-bottom-color: var(--color-brand);
    font-weight: 600;
}

/* Panels */
.msgs-context__panel {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.msgs-context__panel--hidden {
    display: none;
}

/* Secciones de la vacante */
.vacancy-section {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.vacancy-label {
    font-size: 11px;
    font-weight: 600;
    color: #9ca3af;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.vacancy-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--color-text);
    line-height: 1.3;
}

.vacancy-text {
    font-size: 12px;
    color: #4b5563;
    line-height: 1.6;
}

.vacancy-level {
    font-size: 13px;
    font-weight: 600;
    color: var(--color-brand);
}

.vacancy-location {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: #4b5563;
}

.vacancy-location svg {
    color: var(--color-accent);
    flex-shrink: 0;
}

/* Select de estado */
.vacancy-select {
    font-size: 12px;
    font-family: var(--font-base);
    color: var(--color-text);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: 6px 10px;
    outline: none;
    background: #ffffff;
    cursor: pointer;
    transition: border-color var(--transition);
}

.vacancy-select:focus {
    border-color: var(--color-brand);
}

/* Tags de tecnologías */
.vacancy-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.vtag {
    font-size: 10px;
    font-weight: 500;
    padding: 3px 8px;
    border-radius: var(--radius-xs);
    background: #f3f4f6;
    color: #374151;
    border: 1px solid #e5e7eb;
}

.vtag--blue {
    background: #eff6ff;
    color: #1d4ed8;
    border-color: #dbeafe;
}

.vtag--green {
    background: #f0fdf4;
    color: #166534;
    border-color: #bbf7d0;
}

.vtag--orange {
    background: #fff7ed;
    color: #c2410c;
    border-color: #fed7aa;
}

/* ---------------------------------------------------------------
   5. HISTORIAL DE INTERACCIONES (timeline)
--------------------------------------------------------------- */
.history-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    padding: 0;
}

.history-item {
    display: flex;
    gap: 12px;
    position: relative;
    padding-bottom: 20px;
}

.history-item:not(.history-item--last)::before {
    content: '';
    position: absolute;
    left: 7px;
    top: 16px;
    width: 2px;
    bottom: 0;
    background: #e5e7eb;
}

.history-item__dot {
    width: 16px;
    height: 16px;
    border-radius: var(--radius-full);
    flex-shrink: 0;
    margin-top: 2px;
    border: 2px solid #fff;
    box-shadow: 0 0 0 2px currentColor;
}

.history-item__dot--blue {
    background: #3b82f6;
    color: #3b82f6;
}

.history-item__dot--yellow {
    background: #f59e0b;
    color: #f59e0b;
}

.history-item__dot--purple {
    background: #8b5cf6;
    color: #8b5cf6;
}

.history-item__dot--green {
    background: #10b981;
    color: #10b981;
}

.history-item__content {
    flex: 1;
    min-width: 0;
}

.history-item__action {
    font-size: 12px;
    font-weight: 600;
    color: var(--color-text);
}

.history-item__date {
    font-size: 11px;
    color: #9ca3af;
    margin-top: 2px;
}

/* ---------------------------------------------------------------
   6. AJUSTE DEL FOOTER en esta vista
--------------------------------------------------------------- */
/* El footer sigue visible debajo de los paneles */
.main-wrapper {
    display: flex;
    flex-direction: column;
}

/* Mensaje nuevo (animación de entrada) */
@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.msg--new {
    animation: slideInUp 0.2s ease forwards;
}