/* ===================================
   FLUXOS DE CONVERSA - FLOWS EDITOR
   =================================== */

/* Grid de Fluxos (Lista) */
.flows-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 24px;
    padding: 20px 0;
}

.flow-card {
    background: white;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    padding: 0;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.flow-card.existing {
    padding: 0;
}

.flow-card:hover {
    border-color: var(--primary-color);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.15);
    transform: translateY(-2px);
}

.flow-card.new {
    border-style: dashed;
    border-color: #d1d5db;
    padding: 32px 24px;
}

.flow-card.new:hover {
    border-color: var(--primary-color);
    background: #f9fafb;
}

/* Card Header (para fluxos existentes) */
.flow-card-header {
    background: #f9fafb;
    border-bottom: 1px solid #e5e7eb;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.flow-status-badge {
    font-size: 12px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.flow-status-badge.active {
    background: #d1fae5;
    color: #065f46;
}

.flow-status-badge.inactive {
    background: #f3f4f6;
    color: #6b7280;
}

/* Card Body (para fluxos existentes) */
.flow-card-body {
    padding: 24px;
}

.flow-card-body:hover {
    background: #fafafa;
}

.flow-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-size: 28px;
}

.flow-card:not(.new) .flow-icon {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
}

.flow-card.new .flow-icon {
    background: #f3f4f6;
    color: #9ca3af;
}

.flow-card h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 8px;
}

.flow-card p {
    font-size: 14px;
    color: var(--text-light);
    margin: 0;
}

.flow-card .flow-meta {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid #e5e7eb;
    display: flex;
    justify-content: space-around;
    font-size: 13px;
    color: var(--text-light);
}

.flow-card .flow-meta span {
    display: flex;
    align-items: center;
    gap: 6px;
}

/* ===================================
   EDITOR DE FLUXOS - FULL SCREEN
   =================================== */

.flow-editor-fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9999;
    background: #f9fafb;
    display: none;
    flex-direction: column;
}

.flow-editor-fullscreen.active {
    display: flex;
}

/* Header do Editor */
.flow-editor-header {
    background: white;
    border-bottom: 1px solid #e5e7eb;
    padding: 12px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 64px;
    flex-shrink: 0;
}

.flow-editor-title {
    display: flex;
    align-items: center;
    gap: 16px;
}

.flow-editor-title h2 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-dark);
    margin: 0;
}

.flow-editor-title input {
    font-size: 18px;
    font-weight: 600;
    border: none;
    border-bottom: 2px solid transparent;
    padding: 4px 8px;
    background: transparent;
    color: var(--text-dark);
    transition: all 0.2s;
}

.flow-editor-title input:focus {
    outline: none;
    border-bottom-color: var(--primary-color);
    background: #f9fafb;
}

.flow-editor-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.flow-editor-actions .btn {
    padding: 8px 16px;
    font-size: 14px;
}

/* SPRINT 3: Canvas Controls */
.canvas-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 12px;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
}

.canvas-btn {
    background: white;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    color: #6b7280;
}

.canvas-btn:hover {
    background: #f3f4f6;
    border-color: #9ca3af;
    color: var(--text-dark);
}

.canvas-btn.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

.canvas-btn:disabled {
    background: #f9fafb;
    border-color: #e5e7eb;
    color: #d1d5db;
    cursor: not-allowed;
    opacity: 0.5;
}

.canvas-btn:disabled:hover {
    background: #f9fafb;
    border-color: #e5e7eb;
    color: #d1d5db;
}

.canvas-btn i {
    font-size: 14px;
}

.zoom-display {
    min-width: 48px;
    text-align: center;
    font-size: 13px;
    font-weight: 600;
    color: #6b7280;
}

.canvas-separator {
    width: 1px;
    height: 24px;
    background: #d1d5db;
    margin: 0 4px;
}

.btn-back {
    background: transparent;
    color: var(--text-dark);
    border: 1px solid #e5e7eb;
}

.btn-back:hover {
    background: #f3f4f6;
}

/* Container Principal do Editor */
.flow-editor-container {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Sidebar Esquerda - Blocos */
.flow-sidebar {
    width: 280px;
    background: white;
    border-right: 1px solid #e5e7eb;
    overflow-y: auto;
    flex-shrink: 0;
}

.flow-sidebar-header {
    padding: 20px;
    border-bottom: 1px solid #e5e7eb;
    position: sticky;
    top: 0;
    background: white;
    z-index: 10;
}

.flow-sidebar-header h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-dark);
    margin: 0 0 8px 0;
}

.flow-sidebar-header p {
    font-size: 13px;
    color: var(--text-light);
    margin: 0;
}

/* Categorias de Blocos */
.block-category {
    padding: 16px 20px;
    border-bottom: 1px solid #f3f4f6;
}

.block-category-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
}

/* Itens de Bloco (Drag and Drop) */
.block-item {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 8px;
    cursor: grab;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 12px;
}

.block-item:hover {
    border-color: var(--primary-color);
    box-shadow: 0 2px 8px rgba(79, 70, 229, 0.1);
    transform: translateX(4px);
}

.block-item:active {
    cursor: grabbing;
}

.block-item-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.block-item-icon.trigger {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
}

.block-item-icon.action {
    background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
    color: white;
}

.block-item-icon.condition {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: white;
}

.block-item-icon.integration {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: white;
}

.block-item-content {
    flex: 1;
}

.block-item-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-dark);
    margin: 0 0 2px 0;
}

.block-item-desc {
    font-size: 12px;
    color: var(--text-light);
    margin: 0;
}

/* Canvas do Fluxo */
.flow-canvas {
    flex: 1;
    background-color: #fafafa;
    position: relative;
    overflow: auto;
    transition: background 0.3s;
}

/* SPRINT 3: Grid Background */
.flow-canvas.show-grid {
    background-color: #fafafa;
    background-image: 
        linear-gradient(to right, #e0e0e0 1px, transparent 1px),
        linear-gradient(to bottom, #e0e0e0 1px, transparent 1px);
    background-size: 20px 20px;
}

.flow-canvas-inner {
    min-width: 2000px;
    min-height: 2000px;
    position: relative;
    padding: 40px;
    transition: transform 0.1s ease-out;
    transform-origin: 0 0;
}

/* Nós no Canvas */
.flow-node {
    position: absolute;
    background: white;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    min-width: 200px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    cursor: move;
    transition: all 0.2s;
}

.flow-node:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    z-index: 10;
}

.flow-node.selected {
    border-color: var(--primary-color);
    box-shadow: 0 4px 16px rgba(79, 70, 229, 0.2);
    z-index: 11;
}

.flow-node-header {
    padding: 12px 16px;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    align-items: center;
    gap: 10px;
    border-radius: 10px 10px 0 0;
}

.flow-node-header.trigger {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
}

.flow-node-header.action {
    background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
    color: white;
}

.flow-node-header.condition {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: white;
}

.flow-node-icon {
    font-size: 16px;
}

.flow-node-title {
    flex: 1;
    font-size: 14px;
    font-weight: 600;
    margin: 0;
}

.flow-node-delete {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    transition: all 0.2s;
}

.flow-node-delete:hover {
    background: rgba(255, 255, 255, 0.3);
}

.flow-node-body {
    padding: 16px;
}

.flow-node-desc {
    font-size: 13px;
    color: var(--text-light);
    margin: 0;
}

/* Connection Points */
.flow-node-connections {
    display: flex;
    justify-content: space-between;
    padding: 0 16px 12px;
}

.connection-point {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: white;
    border: 2px solid var(--primary-color);
    cursor: pointer;
    transition: all 0.2s;
}

.connection-point:hover {
    transform: scale(1.3);
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.2);
}

.connection-point.input {
    margin-top: -18px;
}

.connection-point.output {
    margin-bottom: -18px;
}

/* Node Connection Ports */
.node-port {
    position: absolute;
    width: 16px;
    height: 16px;
    background: white;
    border: 3px solid var(--primary-color);
    border-radius: 50%;
    cursor: crosshair;
    z-index: 10;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.node-port:hover {
    transform: scale(1.4);
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.2);
    background: var(--primary-color);
}

.node-port:hover i {
    color: white;
}

.node-port i {
    font-size: 6px;
    color: var(--primary-color);
    transition: color 0.2s;
}

.node-port-output {
    right: -8px;
    top: 50%;
    transform: translateY(-50%);
}

.node-port-input {
    left: -8px;
    top: 50%;
    transform: translateY(-50%);
}

/* SVG Connections Layer */
.connections-layer {
    pointer-events: none;
    user-select: none;
}

.temp-connection {
    pointer-events: none;
    user-select: none;
}

/* Painel de Propriedades Lateral Direito */
.flow-properties {
    width: 360px;
    background: white;
    border-left: 1px solid #e5e7eb;
    overflow-y: auto;
    flex-shrink: 0;
    display: none;
}

.flow-properties.active {
    display: block;
}

.flow-properties-header {
    padding: 20px;
    border-bottom: 1px solid #e5e7eb;
    position: sticky;
    top: 0;
    background: white;
    z-index: 10;
}

.flow-properties-header h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-dark);
    margin: 0 0 4px 0;
}

.flow-properties-header p {
    font-size: 13px;
    color: var(--text-light);
    margin: 0;
}

.flow-properties-body {
    padding: 20px;
}

.flow-properties-section {
    margin-bottom: 24px;
}

.flow-properties-section-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Form Groups para Configurações */
.config-group {
    margin-bottom: 20px;
}

.config-group label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-dark);
    margin-bottom: 8px;
}

.config-group input[type="text"],
.config-group input[type="number"],
.config-group textarea,
.config-group select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    font-size: 14px;
    color: var(--text-dark);
    transition: all 0.2s;
}

.config-group input:focus,
.config-group textarea:focus,
.config-group select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.config-group textarea {
    resize: vertical;
    min-height: 100px;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.config-group .hint {
    font-size: 12px;
    color: var(--text-light);
    margin-top: 6px;
    display: block;
}

/* Toggle Switch */
.toggle-group {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid #f3f4f6;
}

.toggle-group:last-child {
    border-bottom: none;
}

.toggle-label {
    font-size: 14px;
    color: var(--text-dark);
    font-weight: 500;
}

.toggle-switch {
    position: relative;
    width: 48px;
    height: 24px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #cbd5e0;
    transition: 0.3s;
    border-radius: 24px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
}

.toggle-switch input:checked + .toggle-slider {
    background-color: var(--primary-color);
}

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(24px);
}

/* Slider Range */
.range-group {
    margin-bottom: 20px;
}

.range-group label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-dark);
    margin-bottom: 8px;
}

.range-value {
    font-weight: 600;
    color: var(--primary-color);
}

.range-group input[type="range"] {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: #e5e7eb;
    outline: none;
    -webkit-appearance: none;
}

.range-group input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.range-group input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    border: none;
}

/* Alert de Configuração (como "Não há nota cadastradas") */
.config-alert {
    background: #fef3c7;
    border: 1px solid #fbbf24;
    border-radius: 8px;
    padding: 12px 16px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin: 16px 0;
}

.config-alert i {
    color: #d97706;
    font-size: 16px;
    margin-top: 2px;
}

.config-alert-content {
    flex: 1;
}

.config-alert-title {
    font-size: 14px;
    font-weight: 600;
    color: #92400e;
    margin: 0 0 4px 0;
}

.config-alert-desc {
    font-size: 13px;
    color: #78350f;
    margin: 0;
}

/* Botões de Ação */
.config-actions {
    display: flex;
    gap: 12px;
    padding-top: 20px;
    border-top: 1px solid #e5e7eb;
    margin-top: 24px;
}

.config-actions .btn {
    flex: 1;
}

/* Estado vazio do canvas */
.flow-empty-state {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    max-width: 400px;
}

.flow-empty-state i {
    font-size: 64px;
    color: #d1d5db;
    margin-bottom: 20px;
}

/* ===================================
   TEMPLATES
   =================================== */

/* Card de Template na lista de flows */
.flow-card.template {
    border-style: dashed;
    border-color: #818cf8;
    background: linear-gradient(135deg, #eef2ff 0%, #e0e7ff 100%);
    padding: 32px 24px;
}

.flow-card.template:hover {
    border-color: #6366f1;
    background: linear-gradient(135deg, #e0e7ff 0%, #c7d2fe 100%);
}

.flow-card.template .flow-icon {
    background: linear-gradient(135deg, #818cf8 0%, #6366f1 100%);
    color: white;
}

/* Grid de templates no modal */
.templates-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
    max-height: 500px;
    overflow-y: auto;
    padding: 4px;
}

/* Card individual de template */
.template-card {
    background: white;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    padding: 20px;
    cursor: pointer;
    transition: all 0.2s;
}

.template-card:hover {
    border-color: var(--primary-color);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.15);
    transform: translateY(-2px);
}

.template-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 12px;
}

.template-icon {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    font-size: 24px;
    margin-bottom: 12px;
    background: linear-gradient(135deg, #818cf8 0%, #6366f1 100%);
    color: white;
}

.template-category {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    padding: 4px 8px;
    border-radius: 6px;
    background: #f3f4f6;
    color: #6b7280;
}

.template-category.atendimento {
    background: #dbeafe;
    color: #1e40af;
}

.template-category.vendas {
    background: #d1fae5;
    color: #065f46;
}

.template-category.suporte {
    background: #fef3c7;
    color: #92400e;
}

.template-category.marketing {
    background: #fce7f3;
    color: #9f1239;
}

.template-card h4 {
    margin: 0 0 8px;
    font-size: 16px;
    font-weight: 600;
    color: #111827;
}

.template-card p {
    margin: 0 0 12px;
    font-size: 14px;
    color: #6b7280;
    line-height: 1.5;
}

.template-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 12px;
    color: #9ca3af;
}

.template-meta i {
    margin-right: 4px;
}

.template-actions {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid #f3f4f6;
}

.template-actions .btn {
    width: 100%;
    font-size: 14px;
}

/* Botões de categoria */
.templates-categories button {
    font-size: 14px;
    border-radius: 8px;
    padding: 8px 16px;
    border: 2px solid #e5e7eb;
    background: white;
    color: #6b7280;
}

.templates-categories button:hover {
    border-color: var(--primary-color);
    background: #f9fafb;
}

.templates-categories button.active {
    border-color: var(--primary-color);
    background: var(--primary-color);
    color: white;
}

.flow-empty-state h3 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 12px;
}

.flow-empty-state p {
    font-size: 14px;
    color: var(--text-light);
    line-height: 1.6;
}

/* Lista de Fluxos (Minhas Pastas sidebar) */
.flows-list {
    background: white;
    border-radius: 12px;
    border: 1px solid #e5e7eb;
    overflow: hidden;
}

.flows-list-header {
    padding: 16px;
    background: #f9fafb;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.flows-list-header h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-dark);
    margin: 0;
}

.flows-list-item {
    padding: 16px;
    border-bottom: 1px solid #f3f4f6;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 12px;
}

.flows-list-item:last-child {
    border-bottom: none;
}

.flows-list-item:hover {
    background: #f9fafb;
}

.flows-list-item.active {
    background: #eff6ff;
    border-left: 3px solid var(--primary-color);
}

.flows-list-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

.flows-list-content {
    flex: 1;
}

.flows-list-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-dark);
    margin: 0 0 4px 0;
}

.flows-list-desc {
    font-size: 12px;
    color: var(--text-light);
    margin: 0;
}

.flows-list-badge {
    background: #eff6ff;
    color: #2563eb;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

/* SPRINT 3: Mini-map */
.flow-minimap {
    position: fixed;
    bottom: 20px;
    right: 380px; /* Deixa espaço para o properties panel (360px + 20px) */
    width: 200px;
    height: 150px;
    background: white;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    z-index: 100;
    overflow: hidden;
    transition: right 0.3s ease; /* Anima quando properties panel abre/fecha */
}

/* Mini-map sem properties panel aberto */
.flow-editor-container:not(:has(.flow-properties.active)) .flow-minimap {
    right: 20px;
}

#minimap-canvas {
    width: 100%;
    height: 100%;
    display: block;
}

.minimap-viewport {
    position: absolute;
    border: 2px solid var(--primary-color);
    background: rgba(79, 70, 229, 0.1);
    pointer-events: none;
    z-index: 1;
    transition: all 0.1s ease-out;
}

/* Responsividade */
@media (max-width: 1200px) {
    .flow-sidebar {
        width: 240px;
    }
    
    .flow-properties {
        width: 320px;
    }
}

@media (max-width: 768px) {
    .flows-grid {
        grid-template-columns: 1fr;
    }
    
    .flow-sidebar,
    .flow-properties {
        position: fixed;
        left: -100%;
        top: 64px;
        bottom: 0;
        z-index: 100;
        transition: left 0.3s ease;
    }
    
    .flow-sidebar.active,
    .flow-properties.active {
        left: 0;
    }
}
