/* =========================================================================
   1. CONTENEDORES Y ESTRUCTURA BASE
   ========================================================================= */

.matches-stack {
    display: flex;
    flex-direction: column;
    gap: 25px;
    margin-top: 30px;
}

/* Wrapper Principal (Tarjeta) */
.match-wrapper {
    background: white;
    border-radius: 24px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
    overflow: hidden;
    transition: all 0.3s ease;
    border: 1px solid rgba(0, 0, 0, 0.05);
    position: relative;
}

.match-wrapper:hover {
    transform: translateY(-3px);
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.15);
}

/* --- Variaciones de Color (Oferta vs Demanda) --- */

/* Oferta */
.match-wrapper.is-offer {
    background: linear-gradient(135deg, #ffffff 0%, #D2E7BA 100%) !important;
    border: 2px solid #AABA96;
    border-left: 5px solid #AABA96;
}

.match-wrapper.is-offer .match-type-pill,
.match-wrapper.is-offer .match-type-pill i {
    color: #2e7d32 !important;
    opacity: 1 !important;
    font-weight: 800;
}

/* Demanda */
.match-wrapper.is-demand {
    background: linear-gradient(135deg, #ffffff 0%, #EFCEB5 100%) !important;
    border: 2px solid #DC9661;
    border-left: 5px solid #DC9661;
}

.match-wrapper.is-demand .match-type-pill,
.match-wrapper.is-demand .match-type-pill i {
    color: #c45938 !important;
    opacity: 1 !important;
    font-weight: 800;
}

/* --- ANIMACIONES VER MÁS --- */

/* Estado inicial de los ocultos (aunque tengan display:none en PHP) */
.vintech-hidden-match {
    opacity: 0;
    transform: translateY(20px);
}

/* Estado final (visible) */
.vintech-fade-in {
    opacity: 1 !important;
    transform: translateY(0) !important;
    transition: all 0.5s cubic-bezier(0.25, 0.8, 0.25, 1);
}

/* Transición para el contenedor del botón al desaparecer */
.load-more-container {
    transition: opacity 0.3s ease;
}

#btn-show-more-matches {
    margin: 0 auto;
    width: auto;
    display: flex;
    align-items: center;
    gap: 8px;
    background: #F8F0FF;
    color: #76288A;
    font-size: 16px;
    padding: 12px 25px;
    border-radius: 5px;
    box-shadow: 0 4px 15px rgba(118, 40, 138, 0.3);
    border: 2px solid #76288A;
}

/* Efecto al pasar el mouse */
#btn-show-more-matches:hover {
    background: #5e1e6e;
    color: white;
}

/* =========================================================================
   2. HEADER Y BADGES
   ========================================================================= */

/* Badge de Score (Esquina Superior Derecha) */
.match-score-badge {
    position: absolute;
    top: 20px;
    right: 25px;
    width: 170px;
    height: 40px;
    padding: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    color: white;
    border-radius: 20px;
    font-weight: 600;
    font-size: 13px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
    z-index: 10;
    letter-spacing: 0.5px;
}

/* Header de la Tarjeta */
.match-summary-card {
    background: transparent !important;
    display: flex;
    align-items: flex-start;
    padding: 25px 30px;
    gap: 25px;
    position: relative;
    z-index: 2;

    /* Espaciado para elementos flotantes en Desktop */
    padding-top: 30px;
    padding-right: 200px;
    /* Espacio para el Badge */
    padding-bottom: 70px;
    /* Espacio para los Botones */
}

.match-info {
    flex: 1;
    width: 100%;
}

.match-type-pill {
    font-size: 10px;
    text-transform: uppercase;
    font-weight: 800;
    letter-spacing: 1px;
    opacity: 0.6;
    margin-bottom: 6px;
    display: block;
}

.match-info h4 {
    margin: 0 0 8px 0;
    font-size: 1.3rem;
    color: #333;
    font-weight: 700;
}

/* Razón IA */
.match-ia-reason {
    font-size: 13px;
    color: #444;
    background: rgba(255, 255, 255, 0.6);
    padding: 6px 12px;
    border-radius: 8px;
    display: inline-block;
    margin: 0;
    backdrop-filter: blur(5px);
    border: 1px solid rgba(255, 255, 255, 0.5);
}

/* =========================================================================
   3. BOTONES DE ACCIÓN (Estilos compartidos y específicos)
   ========================================================================= */

/* Contenedor de botones */
.match-toggle-action {
    position: absolute;
    bottom: 20px;
    right: 25px;
    z-index: 5;
    display: flex;
    gap: 15px;
}

/* Estilos Base Comunes para AMBOS botones (DRY - Don't Repeat Yourself) */
.btn-expand-details,
.request-link-btn {
    width: 170px;
    height: 40px;
    padding: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    border-radius: 20px;
    font-weight: 600;
    /* Peso base */
    font-size: 13px;
    cursor: pointer;
    transition: all 0.3s ease;
}

/* -- A. Botón EXPANDIR (Estilo Glass/Blanco) -- */
.btn-expand-details {
    background: #2D6BC9;
    border: 1px solid rgba(0, 0, 0, 0.1);
    color: white;
    backdrop-filter: blur(5px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

.btn-expand-details:hover {
    background: #1D57A7;
    color: white;
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.15);
}

/* -- B. Botón VINCULAR (Estilo Amarillo) -- */
.request-link-btn {
    background: #FFDC00;
    color: #333333;
    border: none;
    font-weight: 700;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

.request-link-btn:hover {
    background: #CCB000;
    color: #333333;
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.15);
}

.request-link-btn i {
    color: #333333;
}

/* =========================================================================
   4. PANEL DE DETALLES Y CONTENIDO INTERNO
   ========================================================================= */

.match-details-panel {
    display: none;
    background: transparent !important;
    padding: 20px;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
    animation: fadeIn 0.4s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.loading-placeholder {
    text-align: center;
    padding: 30px;
    color: #666;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 12px;
}

/* Grid de Info Superior (IA vs Contexto) */
.match-info-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 25px;
    align-items: stretch;
}

.match-reason-box,
.match-context-box {
    width: 100%;
    height: 100%;
    padding: 20px;
    box-sizing: border-box;
    border-radius: 12px;
    font-size: 13px;
    line-height: 1.5;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    margin: 0 !important;
}

/* Reseteo de márgenes internos */
.match-reason-box p,
.match-context-box p,
.match-reason-box strong,
.match-context-box strong {
    margin: 0 !important;
    padding: 0 !important;
}

.match-reason-box strong,
.match-context-box strong {
    margin-bottom: 8px !important;
    display: block;
    min-height: 18px;
}

/* Estilos Específicos de Cajas de Info */
.match-reason-box {
    background: #d7e9ff;
    color: #333;
    border: none !important;
    /* Sin bordes */
}

.match-reason-box strong {
    color: #76288A;
}

.match-context-box {
    background: #DCDCDC;
    color: #444;
}

.match-context-box strong {
    font-size: 11px;
    text-transform: uppercase;
    color: #777;
    letter-spacing: 0.5px;
}

.match-context-box p {
    font-weight: 600;
    color: #333;
    word-wrap: break-word;
}

/* Layout de Comparación Principal */
.comparison-layout {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 25px;
    margin-top: 25px;
}

.comparison-content {
    background: rgba(255, 255, 255, 0.85);
    border-radius: 16px;
    padding: 25px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.03);
    backdrop-filter: blur(10px);
}

.comparison-row {
    display: flex;
    margin-bottom: 15px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    padding-bottom: 15px;
}

.comparison-row:last-child {
    border: none;
    margin: 0;
    padding: 0;
}

.cmp-label {
    width: 100px;
    font-weight: 700;
    font-size: 12px;
    color: #888;
    text-transform: uppercase;
}

.cmp-values {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    flex: 1;
    font-size: 14px;
}

.cmp-val.mine {
    color: #555;
}

.cmp-val.theirs {
    color: #000;
    font-weight: 600;
}

/* Tarjeta de Acción Lateral (Dentro del panel) */
.action-card {
    background: #2D3436;
    color: white;
    border-radius: 16px;
    padding: 25px;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    height: fit-content;
}

.action-card h5 {
    color: #FFDC00;
    font-size: 18px;
    margin-bottom: 10px;
    font-weight: 700;
}

/* Botón dentro de la tarjeta de acción */
.action-card .request-link-btn {
    width: 100% !important;
    margin-top: 15px;
}

/* --- ESTILO DEL MAPA DE UBICACIÓN --- */

.map-container {
    border-radius: 0 !important;
    border: none !important;
    box-shadow: none !important;
    background: transparent !important;
    overflow: visible !important;
    margin-top: 20px !important;
}

/* Estilo para el título "Ubicación" */
.map-container>div:first-child {
    background: transparent !important;
    border: none !important;
    color: #ccc !important;
    padding: 0 0 8px 0 !important;
    font-size: 11px !important;
    letter-spacing: 1px;
    font-weight: 700;
}

/* APLICAMOS EL REDONDEO SOLO AL MAPA (IFRAME) */
.map-container iframe {
    border-radius: 20px !important;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    display: block;
}

/* =========================================================================
   5. RESPONSIVE (MÓVIL) - CORREGIDO
   ========================================================================= */

@media (max-width: 768px) {

    /* Ajustes del Header de la Tarjeta */
    .match-summary-card {
        flex-direction: column;
        align-items: flex-start;

        padding-top: 70px;
        padding-right: 20px;
        padding-bottom: 20px;
    }

    /* Ajuste del Badge */
    .match-score-badge {
        right: 20px;
        top: 20px;
    }

    /* Ajuste de Botones: SOLUCIÓN AL PROBLEMA "FINITO" */
    .match-toggle-action {
        position: relative;
        bottom: auto;
        right: auto;
        width: 100%;
        margin-top: 25px;

        flex-direction: column;
        align-items: center;
        gap: 15px;
    }

    /* Estilos robustos para los botones en móvil */
    .btn-expand-details,
    .request-link-btn {
        width: 100%;
        height: auto;
        min-height: 45px;
        padding: 12px 0;

        display: flex;
        justify-content: center;
        align-items: center;
        border-radius: 25px;
    }

    /* Grids a una sola columna */
    .comparison-layout {
        grid-template-columns: 1fr;
    }

    .match-info-row {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .comparison-row {
        flex-direction: column;
        gap: 5px;
    }
}

/* =========================================================================
   6. ESTILOS NUEVOS: TAGS, ESTADO Y PDF
   ========================================================================= */

/* 1. Nube de Tags (Chips) */
/* Nube de Tags (Chips) */
.match-tags-cloud {
    margin-bottom: 20px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    padding-bottom: 15px;
    border-bottom: 1px solid #eee;
    /* Línea separadora */
}

.tags-label {
    font-size: 11px;
    font-weight: 700;
    color: #76288A;
    margin-right: 5px;
    text-transform: uppercase;
}

.match-tag {
    background: #E1BEE7;
    /* Lila suave */
    color: #4A148C;
    /* Texto oscuro */
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 700;
    border: 1px solid #D1C4E9;
}

/* 2. Barra de Progreso (Status Tracker) */
.status-tracker {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 15px;
    width: 100%;
    padding: 0 5px;
}

.status-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    z-index: 2;
}

.step-icon {
    width: 30px;
    height: 30px;
    background: #444;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    color: #888;
    transition: all 0.3s;
    border: 2px solid #555;
}

.step-label {
    font-size: 10px;
    margin-top: 5px;
    color: #aaa;
    font-weight: 600;
}

/* Estado Activo */
.status-step.active .step-icon {
    background: #FFDC00;
    color: #333;
    border-color: #FFDC00;
    box-shadow: 0 0 10px rgba(255, 220, 0, 0.4);
}

.status-step.active .step-label {
    color: #FFDC00;
}

/* Línea conectora */
.status-line {
    flex: 1;
    height: 2px;
    background: #555;
    margin: 0 5px;
    margin-bottom: 15px;
    /* Ajuste para alinear con los círculos */
    position: relative;
    z-index: 1;
}

.status-line.active {
    background: #FFDC00;
}

/* =========================================================================
   7. ESTILOS NUEVOS: BARRA DE TAGS LARGA
   ========================================================================= */

.tags-full-row {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 15px;

    background: #DFE2FB;
    /* Fondo blanco limpio */
    padding: 15px 20px;
    border-radius: 12px;
    border: 1px solid rgba(0, 0, 0, 0.05);
    /* Borde sutil */
    margin-bottom: 25px;
    /* Separación de la tabla de abajo */

    /* Sombra suave */
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.03);
}

/* Icono y Texto "Puntos de conexión" */
.tags-header-label {
    font-size: 13px;
    font-weight: 700;
    color: #76288A;
    /* Color Morado Vintech */
    white-space: nowrap;
    /* Evita que el título se rompa */
    display: flex;
    align-items: center;
    gap: 8px;
}

.tags-header-label i {
    font-size: 16px;
    /* Icono un poco más grande */
}

/* Contenedor de los chips */
.tags-list-inline {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    flex: 1;
    /* Ocupa el resto del espacio */
}

/* Estilo de cada Tag individual */
.match-tag-pill {
    background: #F3E5F5;
    /* Lila muy suave */
    color: #4A148C;
    /* Morado oscuro */
    padding: 5px 12px;
    border-radius: 20px;
    /* Redondeado tipo píldora */
    font-size: 12px;
    font-weight: 600;
    border: 1px solid #E1BEE7;
    transition: all 0.2s;
}

.match-tag-pill:hover {
    background: #E1BEE7;
    transform: translateY(-1px);
}

/* RESPONSIVE */
@media (max-width: 768px) {
    .tags-full-row {
        flex-direction: column;
        /* Apilar título y tags en móvil */
        align-items: flex-start;
        gap: 10px;
    }
}

/* =========================================================================
   8.ESTILOS BOTÓN PDF (MODERNO)
   ========================================================================= */

.btn-print-pdf-trigger {
    background: #FF3520;
    color: #ffffff;
    padding: 6px 14px;
    border-radius: 24px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.15);
    letter-spacing: 0.5px;
}

/* Efecto Hover */
.btn-print-pdf-trigger:hover {
    background: #b71c1c;
    color: white;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
}

.btn-print-pdf-trigger i {
    font-size: 16px;
}

/* Asegura que el botón se mantenga rojo en todos sus estados */
.btn-print-pdf-trigger:focus,
.btn-print-pdf-trigger:active,
.btn-print-pdf-trigger:visited {
    background: #FF3520 !important;
    /* Rojo forzado */
    color: #ffffff !important;
    outline: none !important;
    /* Quita el borde azul de selección */
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.15) !important;
}

/* Mantiene el color oscuro al pasar el mouse, incluso si está seleccionado */
.btn-print-pdf-trigger:hover,
.btn-print-pdf-trigger:focus:hover {
    background: #b71c1c !important;
}

/* =========================================================================
   LIMPIEZA DE IMPRESIÓN NATIVA
   (Esto oculta botones si alguien presiona Ctrl+P por error en vez de tu botón)
   ========================================================================= */
@media print {

    .btn-print-pdf-trigger,
    .request-link-btn,
    .btn-expand-details,
    .action-card {
        display: none !important;
    }
}

/* --- NUEVO: SECCIÓN "POR MI CUENTA" --- */

.self-manage-separator {
    height: 1px;
    background-color: rgba(255, 255, 255, 0.2);
    margin: 20px 0;
    width: 100%;
}

.self-manage-section {
    background: rgba(0, 0, 0, 0.2);
    padding: 15px;
    border-radius: 10px;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.self-manage-section h6 {
    color: #f1f1f1;
    margin: 0 0 5px 0;
    font-size: 14px;
    font-weight: 700;
}

.self-manage-section p {
    color: #ccc;
    font-size: 11px;
    margin: 0 0 12px 0;
    line-height: 1.4;
}

.btn-self-manage {
    background: transparent;
    border: 2px solid #aaa;
    color: #ddd;
    width: 100%;
    padding: 8px 0;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-self-manage:hover {
    background: #e74c3c;
    /* Rojo al pasar el mouse */
    border-color: #e74c3c;
    color: white;
}

/* Ocultar en impresión */
@media print {

    .btn-self-manage,
    .self-manage-section {
        display: none !important;
    }
}