/* ═══════════════════════════════════════════════════════════════
   Diagnóstico Extranjería — modal interno (patrón tools-ex32.css)
   ═══════════════════════════════════════════════════════════════ */
/* Overlay autosuficiente (no depende de otros CSS) */
#diag-modal.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 16px;
}
#diag-modal.hidden { display: none !important; }

/* Caja del modal (calcada del patrón .ex-generic-container) */
.diag-container {
    background: var(--bg-primary, #16181c);
    border: 1px solid var(--border, rgba(128,128,128,0.3));
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    max-width: 720px;
    width: 94vw;
    max-height: calc(100dvh - 32px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Cabecera (autosuficiente) */
.diag-container .modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border, rgba(128,128,128,0.25));
    flex-shrink: 0;
}
.diag-container .modal-header h2 { margin: 0; font-size: 17px; }
.diag-container .modal-close {
    border: none;
    background: transparent;
    color: inherit;
    font-size: 18px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 8px;
}
.diag-container .modal-close:hover { background: rgba(128,128,128,0.15); }

/* Barra de progreso bajo el header */
.diag-progress {
    height: 4px;
    background: rgba(128, 128, 128, 0.18);
    flex-shrink: 0;
}
.diag-progress-bar {
    height: 100%;
    width: 0%;
    background: #00BF64;
    transition: width 0.4s ease;
}

/* Cuerpo scrolleable */
.diag-body {
    flex: 1 1 auto;
    min-height: 240px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 16px 18px;
}
.diag-intro {
    margin: 4px 0 12px;
    opacity: 0.85;
}

/* Burbujas del chat */
.diag-msg {
    max-width: 88%;
    padding: 10px 14px;
    border-radius: 12px;
    margin: 6px 0;
    line-height: 1.45;
    white-space: pre-wrap;
    word-wrap: break-word;
}
.diag-msg-user {
    margin-left: auto;
    background: #00BF64;
    color: #fff;
    border-bottom-right-radius: 4px;
}
.diag-msg-ia {
    margin-right: auto;
    background: rgba(128, 128, 128, 0.14);
    border-bottom-left-radius: 4px;
}
.diag-msg-error {
    margin-right: auto;
    background: rgba(217, 83, 79, 0.15);
    color: #d9534f;
    border: 1px solid rgba(217, 83, 79, 0.4);
}
.diag-loading { opacity: 0.7; font-style: italic; }

/* Chips de respuesta rápida */
.diag-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 10px 0;
}
.diag-chip {
    padding: 8px 14px;
    border-radius: 999px;
    border: 1.5px solid #00BF64;
    background: transparent;
    color: inherit;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.15s;
}
.diag-chip:hover { background: rgba(0, 191, 100, 0.12); }

/* Panel de resultado */
.diag-card {
    border: 1px solid rgba(128, 128, 128, 0.25);
    border-left: 5px solid #00BF64;
    border-radius: 12px;
    padding: 16px 18px;
    margin: 14px 0 4px;
}
.diag-card-media { border-left-color: #f0ad4e; }
.diag-card-baja  { border-left-color: #d9534f; }

.diag-card-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
    flex-wrap: wrap;
}
.diag-card-proc { font-weight: 700; font-size: 16px; }
.diag-badge {
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12.5px;
    font-weight: 700;
    white-space: nowrap;
}
.diag-badge-alta  { background: rgba(0, 191, 100, 0.15);  color: #00BF64; }
.diag-badge-media { background: rgba(240, 173, 78, 0.15); color: #d69420; }
.diag-badge-baja  { background: rgba(217, 83, 79, 0.15);  color: #d9534f; }

.diag-modelo {
    display: inline-block;
    margin-top: 10px;
    padding: 5px 12px;
    border-radius: 8px;
    background: rgba(0, 102, 51, 0.12);
    font-weight: 700;
    font-size: 14px;
}
.diag-derivar {
    margin-top: 10px;
    padding: 9px 12px;
    border-radius: 8px;
    background: rgba(240, 173, 78, 0.15);
    border: 1px solid rgba(240, 173, 78, 0.5);
    font-weight: 600;
    font-size: 13.5px;
}
.diag-resumen { margin: 12px 0 4px; line-height: 1.5; }

.diag-lista-titulo {
    margin-top: 12px;
    font-weight: 700;
    font-size: 13.5px;
}
.diag-lista {
    margin: 4px 0 0;
    padding-left: 20px;
}
.diag-lista li { margin: 3px 0; line-height: 1.4; }

.diag-siguiente {
    margin-top: 14px;
    padding: 10px 12px;
    border-radius: 8px;
    background: rgba(0, 191, 100, 0.10);
    font-weight: 600;
}
.diag-acciones {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 14px;
}
.diag-accion-sec {
    padding: 10px 16px;
    border: 1.5px solid #006633;
    border-radius: 8px;
    background: transparent;
    color: inherit;
    font-weight: 700;
    cursor: pointer;
}
.diag-accion-sec:hover { background: rgba(0, 102, 51, 0.12); }
.diag-copiar {
    margin-top: 0;
    padding: 10px 16px;
    border: none;
    border-radius: 8px;
    background: #006633;
    color: #fff;
    font-weight: 700;
    cursor: pointer;
}
.diag-copiar:hover { background: #00804a; }

/* Pie con la entrada */
.diag-footer {
    display: flex;
    gap: 10px;
    padding: 12px 16px;
    border-top: 1px solid rgba(128, 128, 128, 0.2);
    flex-shrink: 0;
}
.diag-footer textarea {
    flex: 1;
    resize: none;
    border-radius: 10px;
    border: 1px solid rgba(128, 128, 128, 0.35);
    padding: 9px 12px;
    font: inherit;
    background: transparent;
    color: inherit;
}
.diag-footer button {
    padding: 0 18px;
    border: none;
    border-radius: 10px;
    background: #00BF64;
    color: #fff;
    font-weight: 700;
    cursor: pointer;
}
.diag-footer button:disabled { opacity: 0.5; cursor: default; }
.diag-header-actions { display: flex; gap: 6px; align-items: center; }
.diag-reset {
    border: none;
    background: transparent;
    font-size: 17px;
    cursor: pointer;
    padding: 4px 6px;
}

/* ── Móvil: pantalla completa con safe areas (patrón de la casa) ── */
@media (max-width: 640px) {
    .diag-container {
        width: 100%;
        height: 100dvh;
        max-height: 100dvh;
        border-radius: 0;
    }
    .diag-container .modal-header {
        padding-top: calc(12px + env(safe-area-inset-top));
        flex-shrink: 0;
    }
    .diag-footer {
        padding-bottom: calc(12px + env(safe-area-inset-bottom));
    }
    .diag-msg { max-width: 94%; }
}
