/* =====================================================
   flow-editor-v2-improved.css
   محرر الرد الآلي المحسّن - تصميم احترافي متقدم
   متطابق مع هوية منصة مدعوم
   ===================================================== */

/* ─── Container ─── */
.flow-editor-container-v2 {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 160px);
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    overflow: hidden;
    position: relative;
    border: 1px solid var(--border-subtle);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
}

/* ─── Toolbar ─── */
.flow-toolbar-v2 {
    padding: 16px 24px;
    background: linear-gradient(135deg, var(--bg-card) 0%, rgba(0, 119, 204, 0.02) 100%);
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    gap: 16px;
    align-items: center;
    z-index: 10;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.flow-toolbar-v2 h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.3px;
}

.flow-toolbar-v2 p {
    margin: 0;
    font-size: 12px;
    color: var(--text-muted);
}

.save-status-v2 {
    font-size: 12px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: var(--bg-elevated);
    border-radius: var(--radius-md);
    transition: all 0.3s ease;
    border: 1px solid transparent;
}

.save-status-v2.saved {
    color: var(--status-success);
    background: rgba(76, 175, 80, 0.1);
    border-color: rgba(76, 175, 80, 0.2);
}

.save-status-v2 svg {
    animation: pulse 0.6s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ─── Main Layout ─── */
.flow-main-v2 {
    flex: 1;
    display: flex;
    position: relative;
    overflow: hidden;
}

/* ─── Sidebar ─── */
.flow-sidebar-v2 {
    width: 260px;
    background: linear-gradient(180deg, var(--bg-card) 0%, rgba(30, 42, 58, 0.5) 100%);
    border-left: 1px solid var(--border-subtle);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    overflow-y: auto;
    z-index: 5;
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.08);
}

.sidebar-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.sidebar-title {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 0 6px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.sidebar-title::before {
    content: '';
    width: 3px;
    height: 3px;
    background: var(--brand-primary);
    border-radius: 50%;
}

/* ─── Draggable Items ─── */
.drag-item-v2 {
    padding: 12px 14px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    cursor: grab;
    font-size: 12px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    user-select: none;
    position: relative;
    overflow: hidden;
}

.drag-item-v2::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(0, 119, 204, 0.1) 0%, transparent 100%);
    opacity: 0;
    transition: opacity 0.2s ease;
}

.drag-item-v2:hover {
    border-color: var(--brand-primary);
    background: var(--bg-card);
    box-shadow: 0 4px 12px rgba(0, 119, 204, 0.15);
    transform: translateY(-2px);
}

.drag-item-v2:hover::before {
    opacity: 1;
}

.drag-item-v2:active {
    cursor: grabbing;
    opacity: 0.8;
    transform: scale(0.98);
}

.node-icon {
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    position: relative;
    z-index: 1;
}

.node-label {
    flex: 1;
    color: var(--text-primary);
    position: relative;
    z-index: 1;
}

/* ─── Canvas Wrapper ─── */
.flow-canvas-wrapper {
    flex: 1;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* ─── Canvas ─── */
.flow-canvas-v2 {
    flex: 1;
    background-color: var(--bg-surface);
    background-image: 
        radial-gradient(circle, var(--border-subtle) 0.5px, transparent 0.5px);
    background-size: 20px 20px;
    background-position: 0 0;
    direction: ltr !important;
    position: relative;
    overflow: hidden;
}

/* ─── Drawflow Node Customization ─── */
.drawflow .drawflow-node {
    background: var(--bg-card);
    border: 2px solid var(--border-subtle);
    border-radius: var(--radius-md);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    padding: 0;
    width: 220px !important;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.drawflow .drawflow-node::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(0, 119, 204, 0.05) 0%, transparent 100%);
    opacity: 0;
    transition: opacity 0.2s ease;
    pointer-events: none;
}

.drawflow .drawflow-node:hover {
    border-color: var(--brand-primary);
    box-shadow: 0 8px 24px rgba(0, 119, 204, 0.2);
    transform: translateY(-2px);
}

.drawflow .drawflow-node:hover::before {
    opacity: 1;
}

.drawflow .drawflow-node.selected {
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px rgba(0, 119, 204, 0.25), 0 8px 24px rgba(0, 119, 204, 0.2);
    background: var(--bg-elevated);
}

.drawflow .drawflow-node.selected::before {
    opacity: 1;
}

.drawflow .drawflow-node .title {
    padding: 12px 14px;
    background: linear-gradient(135deg, var(--bg-elevated) 0%, var(--bg-card) 100%);
    border-bottom: 1px solid var(--border-subtle);
    border-radius: var(--radius-md) var(--radius-md) 0 0;
    font-weight: 700;
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-primary);
    letter-spacing: -0.2px;
}

.drawflow .drawflow-node .content {
    padding: 12px;
    font-size: 12px;
    color: var(--text-primary);
    direction: rtl !important;
    text-align: right;
}

/* ─── Node Inputs ─── */
.node-input, .node-textarea {
    width: 100%;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    padding: 8px 10px;
    font-size: 12px;
    color: var(--text-primary);
    font-family: var(--font-primary);
    margin-top: 6px;
    transition: all 0.2s ease;
}

.node-input::placeholder, .node-textarea::placeholder {
    color: var(--text-muted);
}

.node-input:focus, .node-textarea:focus {
    outline: none;
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px rgba(0, 119, 204, 0.1);
    background: var(--bg-card);
}

.node-textarea {
    resize: vertical;
    min-height: 60px;
    max-height: 120px;
}

/* ─── Connection Lines ─── */
.drawflow .connection .main-path {
    stroke: var(--brand-primary);
    stroke-width: 3px;
    stroke-linecap: round;
    stroke-linejoin: round;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
    transition: all 0.2s ease;
}

.drawflow .connection.selected .main-path {
    stroke-width: 4px;
    filter: drop-shadow(0 0 12px rgba(0, 119, 204, 0.5));
}

/* ─── Connection Points ─── */
.drawflow .point {
    stroke: var(--border-subtle);
    stroke-width: 2px;
    fill: var(--bg-card);
    transition: all 0.2s ease;
}

.drawflow .point:hover {
    fill: var(--brand-primary);
    stroke: var(--brand-primary);
    r: 8;
}

.drawflow .input, .drawflow .output {
    width: 16px !important;
    height: 16px !important;
    background: var(--brand-primary) !important;
    border: 2px solid var(--bg-card) !important;
    border-radius: 50%;
    z-index: 9999 !important;
    pointer-events: all !important;
    cursor: crosshair;
    transition: all 0.2s ease;
    box-shadow: 0 0 8px rgba(0, 119, 204, 0.3);
}

.drawflow .input:hover, .drawflow .output:hover {
    transform: scale(1.35);
    box-shadow: 0 0 16px rgba(0, 119, 204, 0.6);
}

/* ─── Zoom Controls ─── */
.flow-controls-v2 {
    position: absolute;
    bottom: 20px;
    left: 20px;
    display: flex;
    gap: 8px;
    z-index: 10;
    background: var(--bg-card);
    padding: 10px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.control-btn-v2 {
    width: 38px;
    height: 38px;
    border-radius: var(--radius-md);
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    color: var(--text-primary);
}

.control-btn-v2:hover {
    background: var(--brand-primary);
    border-color: var(--brand-primary);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 119, 204, 0.3);
}

.control-btn-v2:active {
    transform: translateY(0);
}

/* ─── Properties Panel ─── */
.flow-properties-panel {
    width: 300px;
    background: var(--bg-card);
    border-left: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    box-shadow: -4px 0 16px rgba(0, 0, 0, 0.12);
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 6;
}

.flow-properties-panel.active {
    transform: translateX(0);
}

.properties-header {
    padding: 18px 20px;
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(135deg, var(--bg-card) 0%, rgba(0, 119, 204, 0.02) 100%);
}

.properties-header h4 {
    margin: 0;
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.2px;
}

.properties-content {
    flex: 1;
    overflow-y: auto;
    padding: 18px 20px;
}

.properties-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-primary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-group input, .form-group textarea, .form-group select {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    padding: 8px 10px;
    font-size: 12px;
    color: var(--text-primary);
    font-family: var(--font-primary);
    transition: all 0.2s ease;
}

.form-group input::placeholder, .form-group textarea::placeholder {
    color: var(--text-muted);
}

.form-group input:focus, .form-group textarea:focus, .form-group select:focus {
    outline: none;
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px rgba(0, 119, 204, 0.1);
    background: var(--bg-card);
}

/* ─── Modal ─── */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.modal-content {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

.modal-header {
    padding: 22px 24px;
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(135deg, var(--bg-card) 0%, rgba(0, 119, 204, 0.02) 100%);
}

.modal-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.3px;
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    padding: 18px 24px;
    border-top: 1px solid var(--border-subtle);
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    background: var(--bg-elevated);
}

/* ─── Buttons ─── */
.btn {
    padding: 8px 16px;
    border-radius: var(--radius-md);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: var(--font-primary);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--brand-primary), var(--brand-accent));
    color: white;
    box-shadow: 0 4px 12px rgba(0, 119, 204, 0.25);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 119, 204, 0.35);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: var(--bg-elevated);
    color: var(--text-primary);
    border: 1px solid var(--border-subtle);
}

.btn-secondary:hover {
    background: var(--bg-card);
    border-color: var(--brand-primary);
}

.btn-ghost {
    background: transparent;
    color: var(--text-primary);
    border: 1px solid transparent;
}

.btn-ghost:hover {
    background: var(--bg-elevated);
    border-color: var(--border-subtle);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 11px;
}

/* ─── Scrollbar Styling ─── */
.flow-sidebar-v2::-webkit-scrollbar,
.properties-content::-webkit-scrollbar,
.modal-content::-webkit-scrollbar {
    width: 6px;
}

.flow-sidebar-v2::-webkit-scrollbar-track,
.properties-content::-webkit-scrollbar-track,
.modal-content::-webkit-scrollbar-track {
    background: var(--bg-surface);
}

.flow-sidebar-v2::-webkit-scrollbar-thumb,
.properties-content::-webkit-scrollbar-thumb,
.modal-content::-webkit-scrollbar-thumb {
    background: var(--bg-elevated);
    border-radius: 3px;
}

.flow-sidebar-v2::-webkit-scrollbar-thumb:hover,
.properties-content::-webkit-scrollbar-thumb:hover,
.modal-content::-webkit-scrollbar-thumb:hover {
    background: var(--border-strong);
}

/* ─── Responsive ─── */
@media (max-width: 1024px) {
    .flow-sidebar-v2 {
        width: 240px;
        padding: 16px;
        gap: 16px;
    }

    .flow-properties-panel {
        width: 280px;
    }

    .flow-editor-container-v2 {
        height: calc(100vh - 140px);
    }
}

@media (max-width: 768px) {
    .flow-sidebar-v2 {
        width: 200px;
        padding: 12px;
        gap: 12px;
    }

    .drag-item-v2 {
        padding: 10px 12px;
        font-size: 11px;
    }

    .node-icon {
        font-size: 14px;
        width: 20px;
        height: 20px;
    }

    .flow-properties-panel {
        width: 260px;
    }

    .flow-editor-container-v2 {
        height: calc(100vh - 120px);
    }
}

@media (max-width: 480px) {
    .flow-sidebar-v2 {
        width: 180px;
        padding: 10px;
        gap: 10px;
    }

    .sidebar-title {
        font-size: 10px;
    }

    .drag-item-v2 {
        padding: 8px 10px;
        font-size: 10px;
        gap: 6px;
    }

    .node-icon {
        font-size: 12px;
        width: 18px;
        height: 18px;
    }

    .flow-properties-panel {
        width: 240px;
    }

    .flow-editor-container-v2 {
        height: calc(100vh - 100px);
    }

    .modal-content {
        width: 95%;
    }
}
