/**
 * Estilos para Productivity Features
 * Validação, Quick Actions, Favoritos e Grid Snap
 */

/* ============================================
   1. VALIDAÇÃO EM TEMPO REAL
   ============================================ */

/* Nó com erro */
.drawflow-node.node-error {
    border: 2px solid var(--danger-color) !important;
    box-shadow: 0 0 0 3px rgba(231, 76, 60, 0.3), 0 6px 20px rgba(0, 0, 0, 0.4) !important;
    animation: shake 0.5s;
}

/* Nó com warning */
.drawflow-node.node-warning {
    border: 2px solid var(--warning-color) !important;
    box-shadow: 0 0 0 3px rgba(243, 156, 18, 0.3), 0 6px 20px rgba(0, 0, 0, 0.4) !important;
}

/* Nó válido */
.drawflow-node.node-valid {
    border: 2px solid var(--success-color) !important;
}

/* Animação de shake para erros */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}

/* Tooltip de validação */
.validation-tooltip {
    position: absolute;
    top: -40px;
    left: 50%;
    transform: translateX(-50%);
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 11px;
    white-space: nowrap;
    z-index: 1000;
    pointer-events: none;
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 500;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    animation: tooltipFadeIn 0.3s ease;
}

@keyframes tooltipFadeIn {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(5px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

.validation-tooltip.validation-error {
    background: var(--danger-color);
    color: white;
}

.validation-tooltip.validation-warning {
    background: var(--warning-color);
    color: white;
}

.validation-tooltip i {
    font-size: 14px;
}

/* Seta do tooltip */
.validation-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
}

.validation-tooltip.validation-error::after {
    border-top-color: var(--danger-color);
}

.validation-tooltip.validation-warning::after {
    border-top-color: var(--warning-color);
}

/* ============================================
   2. QUICK ACTIONS MENU
   ============================================ */

.quick-actions-menu {
    min-width: 250px;
    max-width: 350px;
}

.quick-actions-header {
    padding: 12px 16px;
    background: rgba(52, 152, 219, 0.1);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    color: var(--primary-color);
}

.quick-actions-header i {
    font-size: 16px;
}

/* Melhorias no context menu */
.context-menu {
    backdrop-filter: blur(10px);
}

.context-menu-item {
    position: relative;
    overflow: hidden;
}

.context-menu-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--primary-color);
    transform: translateX(-3px);
    transition: transform 0.2s ease;
}

.context-menu-item:hover::before {
    transform: translateX(0);
}

.context-menu-item .shortcut {
    margin-left: auto;
    font-size: 10px;
    opacity: 0.6;
    font-family: 'Courier New', monospace;
    background: rgba(255, 255, 255, 0.05);
    padding: 2px 6px;
    border-radius: 3px;
}

/* ============================================
   3. FAVORITOS E NÓS RECENTES
   ============================================ */

.favorites-section,
.recent-section {
    padding-bottom: 15px;
    border-bottom: 2px solid rgba(255, 255, 255, 0.1);
    margin-bottom: 15px;
}

.favorites-section .node-category-title {
    color: var(--warning-color) !important;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 8px 0;
}

.favorites-section .node-category-title i {
    animation: starPulse 2s infinite;
}

@keyframes starPulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.2); opacity: 0.8; }
}

.recent-section .node-category-title {
    color: var(--info-color) !important;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 8px 0;
}

.recent-section .node-item {
    position: relative;
}

.recent-section .node-item::before {
    content: '';
    position: absolute;
    left: -10px;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 60%;
    background: linear-gradient(180deg, var(--info-color), transparent);
    border-radius: 2px;
}

/* Botão de remover favorito */
.remove-favorite {
    opacity: 0;
    transition: all 0.2s ease;
}

.node-item:hover .remove-favorite {
    opacity: 1;
}

.remove-favorite:hover {
    transform: scale(1.2);
    color: var(--danger-color) !important;
}

/* Indicador visual de favorito */
.favorites-section .node-item {
    background: linear-gradient(135deg, rgba(243, 156, 18, 0.05) 0%, var(--bg-dark) 100%);
    border-left: 3px solid var(--warning-color);
}

/* ============================================
   4. GRID INTELIGENTE E SNAP
   ============================================ */

/* Controles de grid na toolbar */
.grid-controls {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Botão de snap ativo */
#btnToggleSnap.active,
#btnToggleSnap[style*="success"] {
    background: rgba(46, 204, 113, 0.2);
    color: var(--success-color) !important;
}

/* Visual do grid aprimorado */
#drawflow.grid-visible {
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
    background-size: 20px 20px;
}

/* Grid maior a cada 100px */
#drawflow.grid-visible::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image:
        linear-gradient(rgba(52, 152, 219, 0.1) 1px, transparent 1px),
        linear-gradient(90deg, rgba(52, 152, 219, 0.1) 1px, transparent 1px);
    background-size: 100px 100px;
    pointer-events: none;
}

/* Guias de alinhamento */
.alignment-guide {
    position: absolute;
    background: var(--primary-color);
    opacity: 0.5;
    pointer-events: none;
    z-index: 9999;
    animation: guideAppear 0.2s ease;
}

@keyframes guideAppear {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 0.5;
        transform: scale(1);
    }
}

.alignment-guide-vertical {
    width: 2px;
    height: 100%;
    top: 0;
}

.alignment-guide-horizontal {
    width: 100%;
    height: 2px;
    left: 0;
}

/* Menu de alinhamento */
.align-menu {
    min-width: 220px;
}

.align-menu .context-menu-item i {
    width: 20px;
    text-align: center;
    color: var(--primary-color);
}

/* Nó sendo movido com snap */
.drawflow-node.snapping {
    transition: transform 0.1s ease-out;
}

/* ============================================
   5. NÓ DESABILITADO
   ============================================ */

.drawflow-node.node-disabled {
    opacity: 0.5;
    filter: grayscale(80%);
    position: relative;
}

.drawflow-node.node-disabled::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: repeating-linear-gradient(
        45deg,
        transparent,
        transparent 10px,
        rgba(0, 0, 0, 0.2) 10px,
        rgba(0, 0, 0, 0.2) 20px
    );
    pointer-events: none;
    border-radius: 10px;
}

.drawflow-node.node-disabled .title-box::before {
    content: '⏸ ';
    font-style: normal;
}

/* ============================================
   6. SELEÇÃO MÚLTIPLA
   ============================================ */

.drawflow-node.selected {
    border-color: var(--primary-color) !important;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.4), 0 6px 20px rgba(0, 0, 0, 0.4) !important;
}

.drawflow-node.multi-selected {
    border-color: var(--success-color) !important;
    box-shadow: 0 0 0 3px rgba(46, 204, 113, 0.4), 0 6px 20px rgba(0, 0, 0, 0.4) !important;
}

/* Contador de seleção */
.selection-counter {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: var(--bg-medium);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        transform: translateY(100px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.selection-counter i {
    color: var(--primary-color);
    font-size: 18px;
}

.selection-counter span {
    font-weight: 600;
    color: var(--text-light);
}

/* ============================================
   7. ATALHOS DE TECLADO - INDICADORES
   ============================================ */

.keyboard-hint {
    position: fixed;
    bottom: 20px;
    left: 20px;
    background: rgba(0, 0, 0, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    padding: 15px;
    max-width: 300px;
    display: none;
    z-index: 10000;
    animation: fadeIn 0.3s ease;
}

.keyboard-hint.visible {
    display: block;
}

.keyboard-hint h4 {
    margin: 0 0 10px 0;
    color: var(--primary-color);
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.keyboard-hint-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.keyboard-hint-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    color: var(--text-color);
}

.keyboard-hint-key {
    font-family: 'Courier New', monospace;
    background: rgba(255, 255, 255, 0.1);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    color: var(--text-light);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

/* ============================================
   8. LOADING STATES
   ============================================ */

.node-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.2);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: translate(-50%, -50%) rotate(360deg); }
}

/* ============================================
   9. TOOLTIPS APRIMORADOS
   ============================================ */

.tooltip-enhanced {
    position: absolute;
    background: rgba(0, 0, 0, 0.95);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    white-space: nowrap;
    pointer-events: none;
    z-index: 10000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    animation: tooltipFadeIn 0.2s ease;
}

.tooltip-enhanced::after {
    content: '';
    position: absolute;
    border: 5px solid transparent;
}

.tooltip-enhanced.top::after {
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border-top-color: rgba(0, 0, 0, 0.95);
}

.tooltip-enhanced.bottom::after {
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    border-bottom-color: rgba(0, 0, 0, 0.95);
}

/* ============================================
   10. PERFORMANCE INDICATORS
   ============================================ */

.node-performance-badge {
    position: absolute;
    top: 5px;
    right: 5px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 9px;
    font-family: 'Courier New', monospace;
    z-index: 10;
}

.node-performance-badge.fast {
    background: var(--success-color);
}

.node-performance-badge.medium {
    background: var(--warning-color);
}

.node-performance-badge.slow {
    background: var(--danger-color);
}

/* ============================================
   11. RESPONSIVIDADE
   ============================================ */

@media (max-width: 768px) {
    .quick-actions-menu {
        min-width: 200px;
        max-width: 280px;
        font-size: 12px;
    }

    .validation-tooltip {
        font-size: 10px;
        padding: 6px 10px;
    }

    .grid-controls {
        flex-wrap: wrap;
    }

    .keyboard-hint {
        max-width: 250px;
        font-size: 11px;
    }
}

/* ============================================
   12. DARK MODE ENHANCEMENTS
   ============================================ */

@media (prefers-color-scheme: dark) {
    .validation-tooltip {
        box-shadow: 0 6px 16px rgba(0, 0, 0, 0.6);
    }

    .quick-actions-menu {
        backdrop-filter: blur(20px);
        background: rgba(30, 30, 30, 0.95);
    }

    .node-error {
        box-shadow: 0 0 20px rgba(231, 76, 60, 0.5) !important;
    }

    .node-warning {
        box-shadow: 0 0 20px rgba(243, 156, 18, 0.5) !important;
    }
}

/* ============================================
   13. ANIMAÇÕES SUAVES
   ============================================ */

.drawflow-node {
    transition:
        border-color 0.3s ease,
        box-shadow 0.3s ease,
        opacity 0.3s ease,
        filter 0.3s ease;
}

.context-menu-item {
    transition:
        background-color 0.15s ease,
        padding-left 0.15s ease,
        transform 0.15s ease;
}

.toolbar-btn {
    transition:
        background-color 0.2s ease,
        color 0.2s ease,
        transform 0.2s ease;
}
