/**
 * Visual Analysis Framework Pro - Frontend Styles
 */

/* Container Principal */
.vaf-analysis-container {
    position: relative;
    max-width: 100%;
    margin: 0 auto;
}

.vaf-analysis-wrapper {
    display: flex;
    gap: 20px;
    align-items: flex-start;
}

/* Visor de Imagen */
.vaf-image-viewer {
    flex: 1;
    min-width: 0;
}

.vaf-image-container {
    position: relative;
    height: 100%;
    overflow-y: hidden;
    overflow-x: hidden;
    border: none;
    border-radius: none;
    background: #f9f9f9;
}

.vaf-display-image {
    width: 100%;
    height: auto;
    display: block;
}

.vaf-regions-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    pointer-events: all;
}

/* Regiones - Invisibles por defecto */
.vaf-region {
    fill: transparent !important;
    stroke: transparent !important;
    transition: all 0.2s ease-in-out !important;
    cursor: pointer;
}

/* Hover y highlight */
.vaf-region:hover,
.vaf-region.is-highlighted {
    fill: rgba(0, 90, 156, 0.25) !important;
    stroke: #005A9C !important;
    stroke-width: 2px !important;
}

/* Región visible (cuando se activa desde la tabla) */
.vaf-region.is-visible {
    fill: rgba(0, 90, 156, 0.15) !important;
    stroke: rgba(0, 90, 156, 0.5) !important;
    stroke-width: 1px !important;
}

/* Región oculta */
.vaf-region.is-hidden {
    display: none !important;
}

/* Animación de highlight temporal */
@keyframes vaf-pulse {
    0% { opacity: 1; }
    50% { opacity: 0.5; }
    100% { opacity: 1; }
}

.vaf-region.is-pulsing {
    animation: vaf-pulse 1s ease-in-out 3;
}

/* Panel de Control */
.vaf-control-panel {
    width: 350px;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.vaf-control-header {
    padding: 15px 20px;
    background: linear-gradient(135deg, #005A9C 0%, #0073c4 100%);
    color: #fff;
}

.vaf-control-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}

.vaf-control-content {
    padding: 15px;
    max-height: calc(80vh - 60px);
    overflow-y: auto;
}

/* Árbol de regiones */
.vaf-regions-tree {
    list-style: none;
    padding: 0;
    margin: 0;
}

/* Grupo */
.vaf-group {
    margin-bottom: 10px;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    overflow: hidden;
    background: #fff;
}

.vaf-group-header {
    display: flex;
    align-items: center;
    padding: 12px 15px;
    background: #f8f9fa;
    cursor: pointer;
    user-select: none;
    transition: background 0.2s;
}

.vaf-group-header:hover {
    background: #e9ecef;
}

.vaf-group-toggle {
    display: inline-block;
    width: 20px;
    height: 20px;
    margin-right: 10px;
    text-align: center;
    transition: transform 0.2s;
}

.vaf-group.is-expanded .vaf-group-toggle {
    transform: rotate(90deg);
}

.vaf-group-name {
    flex: 1;
    font-weight: 600;
    color: #333;
}

.vaf-group-count {
    padding: 2px 8px;
    background: #005A9C;
    color: #fff;
    border-radius: 12px;
    font-size: 12px;
}

.vaf-group-body {
    display: none;
    padding: 10px 15px;
    background: #fafbfc;
}

.vaf-group.is-expanded .vaf-group-body {
    display: block;
}

/* Región individual */
.vaf-region-row {
    display: flex;
    align-items: center;
    padding: 10px;
    margin-bottom: 8px;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    transition: all 0.2s;
}

.vaf-region-row:last-child {
    margin-bottom: 0;
}

.vaf-region-row:hover {
    background: #f0f7ff;
    border-color: #005A9C;
    transform: translateX(3px);
}

.vaf-region-name {
    flex: 1;
    font-size: 14px;
    color: #333;
}

.vaf-region-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Toggle switch para visibilidad */
.vaf-visibility-toggle {
    position: relative;
    width: 44px;
    height: 24px;
}

.vaf-visibility-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.vaf-visibility-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .3s;
    border-radius: 24px;
}

.vaf-visibility-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .3s;
    border-radius: 50%;
}

.vaf-visibility-toggle input:checked + .vaf-visibility-slider {
    background-color: #005A9C;
}

.vaf-visibility-toggle input:checked + .vaf-visibility-slider:before {
    transform: translateX(20px);
}

/* Botón localizar */
.vaf-locate-btn {
    padding: 5px 12px;
    background: #005A9C;
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

.vaf-locate-btn:hover {
    background: #004080;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 90, 156, 0.3);
}

/* Regiones sin grupo */
.vaf-ungrouped-section {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 2px dashed #ffc107;
}

.vaf-ungrouped-header {
    display: flex;
    align-items: center;
    margin-bottom: 15px;
}

.vaf-ungrouped-header h4 {
    margin: 0;
    color: #666;
    font-size: 14px;
    flex: 1;
}

.vaf-ungrouped-badge {
    padding: 2px 8px;
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffc107;
    border-radius: 12px;
    font-size: 12px;
}

/* Controles móviles */
.vaf-mobile-controls {
    display: none;
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 100;
}

.vaf-mobile-toggle {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #005A9C;
    color: #fff;
    border: none;
    box-shadow: 0 4px 12px rgba(0, 90, 156, 0.3);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

.vaf-mobile-toggle:hover {
    background: #004080;
}

/* Drawer móvil */
.vaf-mobile-drawer {
    position: fixed;
    top: 0;
    right: -100%;
    width: 85%;
    max-width: 380px;
    height: 100%;
    background: #fff;
    box-shadow: -2px 0 10px rgba(0, 0, 0, 0.2);
    z-index: 101;
    transition: right 0.3s ease;
    overflow-y: auto;
}

.vaf-mobile-drawer.is-open {
    right: 0;
}

.vaf-mobile-drawer-header {
    position: sticky;
    top: 0;
    padding: 15px;
    background: linear-gradient(135deg, #005A9C 0%, #0073c4 100%);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.vaf-mobile-drawer-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 24px;
    cursor: pointer;
}

.vaf-mobile-drawer-content {
    padding: 15px;
}

/* Overlay móvil */
.vaf-mobile-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 100;
    display: none;
}

.vaf-mobile-overlay.is-active {
    display: block;
}

/* Responsive */
@media (max-width: 768px) {
    .vaf-analysis-wrapper {
        flex-direction: column;
    }
    
    .vaf-control-panel {
        display: none;
    }
    
    .vaf-mobile-controls {
        display: block;
    }
    
    .vaf-image-container {
        height: 60vh;
    }
    
    .vaf-region-row {
        padding: 12px 10px;
    }
    
    .vaf-region-name {
        font-size: 13px;
    }
    
    .vaf-locate-btn {
        padding: 6px 10px;
        font-size: 12px;
    }
}

@media (max-width: 480px) {
    .vaf-mobile-drawer {
        width: 100%;
        max-width: none;
    }
}

/* Indicador de carga */
.vaf-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
}

.vaf-loading-spinner {
    border: 3px solid #f3f3f3;
    border-top: 3px solid #005A9C;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: vaf-spin 1s linear infinite;
    margin: 0 auto 10px;
}

@keyframes vaf-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Estados vacíos */
.vaf-empty-state {
    text-align: center;
    padding: 40px 20px;
    color: #666;
}

.vaf-empty-state-icon {
    font-size: 48px;
    color: #ddd;
    margin-bottom: 10px;
}

.vaf-empty-state-text {
    font-size: 14px;
}

/* Tooltips */
.vaf-tooltip {
    position: absolute;
    background: #333;
    color: #fff;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 12px;
    white-space: nowrap;
    z-index: 1000;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s;
}

.vaf-tooltip.is-visible {
    opacity: 1;
}

.vaf-tooltip:after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -5px;
    border-width: 5px;
    border-style: solid;
    border-color: #333 transparent transparent transparent;
}

/* Error messages */
.vaf-error {
    padding: 15px;
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    border-radius: 4px;
    color: #721c24;
    margin: 20px 0;
}










/* Filtrado por categoría */
.vaf-region.is-category-filtered {
    stroke-width: 2px !important;
    stroke-dasharray: 5, 3;
    animation: vaf-category-pulse 2s ease-in-out infinite;
}

@keyframes vaf-category-pulse {
    0%, 100% { 
        opacity: 0.7; 
        stroke-opacity: 0.5;
    }
    50% { 
        opacity: 1; 
        stroke-opacity: 1;
    }
}

/* Transición suave al filtrar */
.vaf-region.vaf-fade-in {
    animation: vafFadeIn 0.5s ease-in;
}

@keyframes vafFadeIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Indicador de categoría activa */
.vaf-analysis-container[data-active-category]::before {
    content: attr(data-active-category);
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(13, 110, 253, 0.9);
    color: white;
    padding: 5px 15px;
    border-radius: 20px;
    font-size: 12px;
    z-index: 100;
    pointer-events: none;
}