/* ==============================================
   ARCHIVO: master-api-panels.css - MASTER API PANELS
   DESCRIPCIÓN: Estilos idénticos a smability-panels.css
   ============================================== */

/* === CONTENEDOR PRINCIPAL === */
#masterAPIPanelContainer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 3000; /* Mayor z-index que smability panels */
}

/* === PANEL PRINCIPAL MASTER API - IDÉNTICO A SMABILITY === */
.master-api-panel {
    position: fixed;
    bottom: 20px; /* ← CAMBIO: Igual que smability (bottom, no top) */
    right: 20px;
    width: 650px; /* ← CAMBIO: Igual que smability (650px, no 380px) */
    background: var(--master-api-ias-bg);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.15);
    border: 2px solid var(--master-api-ias-color);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    z-index: 3001;
    max-height: 55vh; /* ← CAMBIO: Igual que smability */
    overflow-y: auto;
    transition: all 0.3s ease;
    pointer-events: all;
    font-family: 'DIN Pro', Arial, sans-serif;
    transform: translateX(100%);
    opacity: 0;
}

.master-api-panel.show {
    transform: translateX(0);
    opacity: 1;
}

/* === HEADER DEL PANEL - IDÉNTICO === */
.master-api-header {
    background: var(--master-api-header-bg);
    padding: 16px;
    border-radius: 12px 12px 0 0;
    border-bottom: 1px solid rgba(0,0,0,0.08);
    position: relative;
    display: flex;
    align-items: center; /* ← CAMBIO: center, no flex-start */
    justify-content: space-between;
    transition: background-color 0.3s ease;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.master-api-header-left {
    flex: 1;
}

.master-api-header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.master-api-panel-title {
    font-size: 18px;
    font-weight: bold;
    color: #000; /* ← CAMBIO: #000, no #1a1a1a */
    margin: 0 0 4px 0; /* ← CAMBIO: Agregar margen inferior */
    font-family: 'DIN Pro', Arial, sans-serif;
    line-height: 1.2;
}

.master-api-panel-subtitle {
    font-size: 12px;
    color: #666;
    margin: 0; /* ← CAMBIO: Sin margen superior */
    font-family: 'DIN Pro', Arial, sans-serif;
    font-weight: normal;
}

.master-api-close-btn {
    width: 24px; /* ← CAMBIO: 24px, no 30px */
    height: 24px; /* ← CAMBIO: 24px, no 30px */
    border-radius: 50%;
    border: none;
    background: rgba(0,0,0,0.1);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px; /* ← CAMBIO: 16px, no 24px */
    color: #666;
    font-family: 'DIN Pro', Arial, sans-serif;
    transition: all 0.2s ease;
}

.master-api-close-btn:hover {
    background: rgba(0,0,0,0.2);
    transform: scale(1.1);
}

/* === CONTENIDO DEL PANEL === */
.master-api-panel-content {
    padding: 16px;
}

/* === SECCIÓN IAS PRINCIPAL - IDÉNTICA === */
.master-api-ias-section {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
    padding: 14px;
    background: var(--master-api-ias-bg);
    border-radius: 10px;
    transition: all 0.3s ease;
    position: relative;
    border: 1px solid var(--master-api-ias-color);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
}

.master-api-ias-emoji {
    font-size: 24px; /* ← CAMBIO: 24px, no 36px */
}

.master-api-ias-indicator {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #ffff00;
}

.master-api-ias-value {
    font-size: 24px;
    font-weight: bold;
    color: #000;
    font-family: 'DIN Pro', Arial, sans-serif;
}

.master-api-ias-status {
    margin-left: auto;
    text-align: right;
}

/* NUEVO: Estructura de etiquetas Status/Risk - IDÉNTICA */
.master-api-status-row {
    display: flex;
    align-items: center;
    gap: 4px;
    margin: 2px 0;
}

.master-api-status-label {
    font-size: 12px;
    color: #000;
    font-family: 'DIN Pro', Arial, sans-serif;
    font-weight: bold;
}

.master-api-status-value {
    font-size: 12px;
    font-weight: bold;
    color: #000;
    font-family: 'DIN Pro', Arial, sans-serif;
}

/* === GRID DE DATOS - IDÉNTICO === */
.master-api-data-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 16px;
}

.master-api-data-item {
    background: var(--master-api-data-bg);
    padding: 10px;
    border-radius: 8px;
    font-size: 12px;
    border: 1px solid var(--master-api-ias-color);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    transition: all 0.2s ease;
}

.master-api-data-item:hover {
    background: var(--master-api-data-bg-hover);
    transform: translateY(-1px);
    box-shadow: 0 2px 6px var(--master-api-ias-color);
}

.master-api-data-label {
    color: #666;
    font-size: 10px;
    margin-bottom: 2px;
    font-family: 'DIN Pro', Arial, sans-serif;
}

.master-api-data-value {
    font-weight: bold;
    color: #000;
    font-family: 'DIN Pro', Arial, sans-serif;
}

/* === FOOTER DEL PANEL - IDÉNTICO === */
.master-api-footer {
    padding: 12px 16px;
    border-top: 1px solid rgba(0,0,0,0.06);
    background: var(--master-api-footer-bg);
    border-radius: 0 0 12px 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 11px;
    color: #666;
    font-family: 'DIN Pro', Arial, sans-serif;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.master-api-last-update {
    font-weight: bold;
}

.master-api-branding {
    color: #4264fb;
    font-weight: bold;
    text-decoration: none;
}

.master-api-branding:hover {
    color: #3251d8;
}

/* === RESPONSIVE - IDÉNTICO === */
@media (max-width: 768px) {
    .master-api-panel {
        left: 10px;
        right: auto;
        width: calc(100vw - 20px);
        max-width: none;
        max-height: 70vh;
    }
    
    .master-api-data-grid {
        grid-template-columns: 1fr;
    }
}

/* === SCROLLBAR STYLING - IDÉNTICO === */
.master-api-panel::-webkit-scrollbar {
    width: 6px;
}

.master-api-panel::-webkit-scrollbar-track {
    background: rgba(0,0,0,0.1);
    border-radius: 3px;
}

.master-api-panel::-webkit-scrollbar-thumb {
    background: rgba(0,0,0,0.3);
    border-radius: 3px;
}

.master-api-panel::-webkit-scrollbar-thumb:hover {
    background: rgba(0,0,0,0.5);
}

/* === TIPOGRAFÍA GLOBAL - IDÉNTICA === */
.master-api-panel *,
.master-api-panel *::before,
.master-api-panel *::after {
    font-family: 'DIN Pro', Arial, sans-serif !important;
    box-sizing: border-box;
}

/* === COMPATIBILIDAD - IDÉNTICA === */
.master-api-panel button {
    font-family: 'DIN Pro', Arial, sans-serif;
    border: none;
    outline: none;
}

.master-api-panel select {
    font-family: 'DIN Pro', Arial, sans-serif;
    outline: none;
}

/* === Z-INDEX HIERARCHY === */
#masterAPIPanelContainer {
    z-index: 3000;
}

.master-api-panel {
    z-index: 3001;
}

/* === MEJORAS PARA ALTA DENSIDAD - IDÉNTICAS === */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .master-api-panel-title,
    .master-api-ias-value,
    .master-api-data-value {
        text-rendering: optimizeLegibility;
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }
}

/* === TRANSICIONES SUAVES === */
* {
    transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
}

/* === ELEMENTOS FALTANTES === */

/* Botón AireGPT */
.master-api-whatsapp-popup {
    background: rgba(37, 211, 102, 0.9);
    padding: 8px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: white;
    text-decoration: none;
    font-weight: bold;
    font-family: 'DIN Pro', Arial, sans-serif;
}

.master-api-whatsapp-popup:hover {
    background: rgba(37, 211, 102, 1);
    transform: scale(1.05);
}

.master-api-whatsapp-popup svg {
    width: 16px;
    height: 16px;
    fill: white;
}

/* Barra IAS */
.master-api-ias-bar-container {
    margin: 12px 16px;
    padding: 0;
    background: transparent;
}

.master-api-ias-bar {
    width: 100%;
    height: 12px;
    background: linear-gradient(
        to right,
        #00e400 0%,     /* Good 0-50 */
        #00e400 25%,    
        #ffff00 25%,    /* Moderate 51-100 */
        #ffff00 50%,    
        #ff7e00 50%,    /* Unhealthy for Sensitive 101-150 */
        #ff7e00 75%,    
        #ff0000 75%,    /* Unhealthy 151-200 */
        #ff0000 87.5%,  
        #8f3f97 87.5%,  /* Very Unhealthy 201-300 */
        #8f3f97 100%    
    );
    border-radius: 6px;
    border: 1px solid rgba(0,0,0,0.1);
    position: relative;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.master-api-ias-bar::after {
    content: '';
    position: absolute;
    top: -2px;
    bottom: -2px;
    width: 3px;
    background: #000;
    border-radius: 2px;
    left: var(--ias-position, 43.5%);
    box-shadow: 0 0 4px rgba(0,0,0,0.3);
    transition: left 0.3s ease;
}

.master-api-ias-bar-labels {
    display: flex;
    justify-content: space-between;
    margin-top: 4px;
    font-size: 8px;
    color: #666;
    font-family: 'DIN Pro', Arial, sans-serif;
    padding: 0 2px;
}

/* === BOTÓN DE ACCIÓN CON ANCHO COMPLETO === */
.master-api-action-buttons {
    display: flex;
    justify-content: center;
    margin-top: 16px;
    margin-bottom: 16px;
    padding: 0; /* Padding igual al del header */
}

.master-api-btn {
    width: 100%; /* ← CLAVE: Ancho completo */
    max-width: none; /* Remover límite de ancho */
    padding: 12px 24px;
    border: 2px solid #4264fb;
    border-radius: 8px;
    background: rgba(66, 100, 251, 0.05);
    cursor: pointer;
    font-size: 14px;
    text-align: center;
    transition: all 0.3s ease;
    text-decoration: none;
    color: #4264fb;
    font-weight: bold;
    font-family: 'DIN Pro', Arial, sans-serif;
    box-shadow: 0 2px 8px rgba(66, 100, 251, 0.1);
    display: block; /* Asegurar que tome todo el ancho */
}

.master-api-btn:hover {
    background: rgba(66, 100, 251, 0.15);
    border-color: #3251d8;
    color: #3251d8;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(66, 100, 251, 0.2);
}

/* Asegurar que el header del gráfico tenga el mismo padding */
.master-api-inline-chart-header > div {
    margin: 0; /* Mismo margen que el botón */
}

/* Contenido expandido */
.master-api-expanded-content {
    transition: all 0.3s ease;
    overflow: hidden;
}

.master-api-expanded-content.show {
    display: block !important;
}

/* Sección IAS clickeable */
.master-api-ias-section.master-api-clickable {
    cursor: pointer;
    user-select: none;
}

.master-api-ias-section.master-api-clickable:hover {
    background: var(--master-api-ias-bg-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px var(--master-api-ias-color);
}

/* === GRÁFICO INLINE PARA MASTER API === */
.master-api-inline-chart-container {
    border-top: 1px solid rgba(0,0,0,0.1);
    padding-top: 16px;
    margin-top: 16px;
}

.master-api-inline-chart-header {
    margin-bottom: 12px;
}

.master-api-inline-chart-controls {
    display: flex;
    gap: 8px;
    align-items: center;
    justify-content: center;
    padding: 10px 12px;
    background: rgba(66, 100, 251, 0.04);
    border-radius: 8px;
    border: 1px solid rgba(66, 100, 251, 0.1);
}

.master-api-inline-chart-controls label {
    font-size: 11px;
    color: #666;
    font-weight: bold;
    white-space: nowrap;
    font-family: 'DIN Pro', Arial, sans-serif;
}

.master-api-inline-chart-controls select {
    font-size: 10px;
    padding: 3px 6px;
    border: 1px solid #ccc;
    border-radius: 4px;
    background: white;
    min-width: 120px;
    font-family: 'DIN Pro', Arial, sans-serif;
}

/* CORREGIDO: Sin fondo blanco en el área del gráfico */
.master-api-inline-chart-area {
    background: transparent; /* ← CAMBIO: De blanco a transparente */
    border-radius: 8px;
    padding: 12px;
    min-height: 250px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(0,0,0,0.06);
    position: relative;
    /* Removido backdrop-filter que podría causar efectos visuales */
}

.master-api-chart-placeholder {
    width: 100%;
    height: 200px;
    background: linear-gradient(135deg, rgba(66, 100, 251, 0.08) 0%, rgba(118, 75, 162, 0.08) 100%);
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-family: 'DIN Pro', Arial, sans-serif;
    color: #666;
    border: 2px dashed rgba(66, 100, 251, 0.2);
}

/* Contenedor para gráfico real de Plotly */
#masterAPIInlineChart {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: none;
    background: transparent !important; /* ← AGREGAR: Forzar transparente */
}

#masterAPIInlineChart.active {
    display: block;
}

/* CORREGIDO: Cambiar a transparente para test final */
#masterAPIInlineChart,
#masterAPIInlineChart .plotly-graph-div,
#masterAPIInlineChart svg,
#masterAPIInlineChart .plot-container {
    background-color: transparent !important;
    background: transparent !important;
}

/* Asegurar que no aparezcan controles residuales */
#masterAPIInlineChart .modebar {
    display: none !important;
}

#masterAPIInlineChart .modebar-container {
    display: none !important;
}

/* === LOGO SMABILITY === */
.master-api-logo {
    filter: brightness(0) invert(1);
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.master-api-logo:hover {
    transform: scale(1.1);
    filter: brightness(0) invert(1) drop-shadow(0 0 8px rgba(255,255,255,0.5));
}
