/* ============================================================
   ICTONE PRACTICAL LAB — FLOWCHART DESIGNER STYLES
   Scoped styles for the Flowchart Designer module
   ============================================================ */

.flowchart-lab-page {
    background-color: var(--bg-secondary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.flowchart-lab-main {
    padding-top: 5rem;
    padding-bottom: 0;
    flex: 1 0 auto;
    display: flex;
    flex-direction: column;
}

/* ── Workspace Header ── */
.flowchart-workspace-header {
    background: #FFFFFF;
    border-bottom: 1px solid var(--border-subtle);
    padding: 0.75rem 1.5rem;
    box-shadow: 0 1px 3px rgba(24, 31, 58, 0.04);
}

.flowchart-header-inner {
    max-width: 1700px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.25rem;
    flex-wrap: wrap;
}

.flowchart-title-group {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.flowchart-title-wrapper {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.flowchart-page-title {
    font-size: 1.35rem;
    font-weight: 800;
    color: var(--primary-dark);
    letter-spacing: -0.02em;
    margin: 0;
    line-height: 1.2;
}

.flowchart-page-subtitle {
    font-size: 0.86rem;
    color: var(--text-muted);
    margin: 0;
}

/* ── Header Actions & Toolbars ── */
.flowchart-actions-toolbar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.flowchart-btn-group {
    display: inline-flex;
    align-items: center;
    background: var(--bg-white);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.flowchart-btn-group .btn-flowchart-action {
    border: none;
    border-radius: 0;
    border-right: 1px solid var(--border-subtle);
}

.flowchart-btn-group .btn-flowchart-action:last-child {
    border-right: none;
}

.btn-flowchart-action {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.48rem 0.8rem;
    font-size: 0.84rem;
    font-weight: 600;
    color: var(--primary-dark);
    background: var(--bg-white);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition-fast);
    font-family: inherit;
    user-select: none;
}

.btn-flowchart-action:hover:not(:disabled) {
    background: var(--bg-soft-blue);
    border-color: var(--accent-blue);
    color: var(--accent-blue);
}

.btn-flowchart-action:active:not(:disabled) {
    transform: translateY(1px);
}

.btn-flowchart-action:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.btn-flowchart-primary {
    background: var(--accent-blue);
    color: #FFFFFF;
    border-color: var(--accent-blue);
    box-shadow: 0 2px 8px rgba(79, 124, 255, 0.28);
}

.btn-flowchart-primary:hover:not(:disabled) {
    background: #3B66E8;
    border-color: #3B66E8;
    color: #FFFFFF;
    box-shadow: 0 4px 14px rgba(79, 124, 255, 0.38);
}

.btn-flowchart-danger:hover:not(:disabled) {
    background: #FEF2F2;
    border-color: #EF4444;
    color: #EF4444;
}

.flowchart-zoom-val {
    font-size: 0.82rem;
    font-weight: 600;
    padding: 0 0.5rem;
    color: var(--text-muted);
    min-width: 48px;
    text-align: center;
}

/* ── Main Workspace Body ── */
.flowchart-workspace-body {
    max-width: 1700px;
    margin: 0 auto;
    height: calc(100vh - 128px);
    min-height: 580px;
    display: flex;
    background: #FFFFFF;
    border-radius: 0;
    box-shadow: 0 4px 20px rgba(15, 23, 42, 0.08);
    border: 1px solid var(--border-medium);
    border-top: none;
    border-bottom: none;
    overflow: hidden;
    position: relative;
    width: 100%;
}

/* ── Left Symbols Palette ── */
.flowchart-palette-panel {
    width: 260px;
    flex-shrink: 0;
    background: #F8FAFC;
    border-right: 1px solid var(--border-medium);
    display: flex;
    flex-direction: column;
    height: 100%;
    user-select: none;
}

.flowchart-palette-header {
    height: 38px;
    background: #EEF2F6;
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1rem;
    font-size: 0.76rem;
    font-weight: 700;
    color: #475569;
    letter-spacing: 0.06em;
}

.flowchart-palette-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.85rem;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.palette-item {
    background: #FFFFFF;
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-sm);
    padding: 0.65rem 0.85rem;
    display: flex;
    align-items: center;
    gap: 0.85rem;
    cursor: grab;
    transition: var(--transition-fast);
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
}

.palette-item:hover {
    border-color: var(--accent-blue);
    background: #F0F7FF;
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(79, 124, 255, 0.12);
}

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

.palette-preview-svg {
    width: 44px;
    height: 32px;
    flex-shrink: 0;
}

.palette-item-info {
    display: flex;
    flex-direction: column;
}

.palette-item-name {
    font-size: 0.84rem;
    font-weight: 700;
    color: var(--primary-dark);
}

.palette-item-hint {
    font-size: 0.72rem;
    color: var(--text-muted);
}

.flowchart-palette-footer {
    padding: 0.65rem 0.85rem;
    border-top: 1px solid var(--border-subtle);
    font-size: 0.72rem;
    color: var(--text-muted);
    text-align: center;
    background: #F8FAFC;
}

/* ── Right Flowchart Canvas Area ── */
.flowchart-canvas-panel {
    flex: 1;
    height: 100%;
    position: relative;
    overflow: hidden;
    background-color: #FAFCFF;
    background-image: radial-gradient(#CBD5E1 1px, transparent 1px);
    background-size: 20px 20px;
    display: flex;
    flex-direction: column;
}

.flowchart-canvas-viewport {
    flex: 1;
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
    cursor: default;
}

.flowchart-canvas-viewport.panning {
    cursor: grab;
}

.flowchart-canvas-viewport.panning:active {
    cursor: grabbing;
}

.flowchart-svg-root {
    width: 100%;
    height: 100%;
    display: block;
    user-select: none;
}

/* ── Flowchart SVG Elements ── */
.fc-node {
    cursor: move;
}

.fc-node-shape {
    fill: #FFFFFF;
    stroke: #1E293B;
    stroke-width: 2;
    transition: stroke 0.15s, stroke-width 0.15s, filter 0.15s;
    filter: drop-shadow(0 2px 4px rgba(15, 23, 42, 0.08));
}

.fc-node:hover .fc-node-shape {
    stroke: #3B82F6;
}

.fc-node.selected .fc-node-shape {
    stroke: #2563EB;
    stroke-width: 2.5;
    fill: #F0F7FF;
    filter: drop-shadow(0 0 6px rgba(37, 99, 235, 0.35));
}

.fc-node-text {
    font-family: 'Inter', -apple-system, sans-serif;
    font-size: 13px;
    font-weight: 600;
    fill: #1E293B;
    text-anchor: middle;
    dominant-baseline: central;
    pointer-events: none;
}

/* Connection Port Handles */
.fc-port-hit {
    fill: transparent;
    cursor: crosshair;
    pointer-events: all;
}

.fc-port {
    fill: #3B82F6;
    stroke: #FFFFFF;
    stroke-width: 2;
    cursor: crosshair;
    pointer-events: none;
    opacity: 0.75;
    transition: opacity 0.15s ease, fill 0.15s ease, r 0.15s ease;
}

.fc-node:hover .fc-port,
.fc-node.selected .fc-port,
.flowchart-canvas-panel.is-connecting .fc-port {
    opacity: 1;
    fill: #2563EB;
}

.fc-node:hover .fc-port-hit:hover + .fc-port,
.fc-port-hit:hover + .fc-port,
.fc-port.port-hovered,
.flowchart-canvas-panel.is-connecting .fc-port-hit:hover + .fc-port {
    fill: #10B981; /* Glowing emerald green on ready to connect */
    stroke: #FFFFFF;
    stroke-width: 2.5;
    opacity: 1;
}

/* Connecting Lines & Arrows */
.fc-edge-path {
    fill: none;
    stroke: #334155;
    stroke-width: 2;
    cursor: pointer;
    transition: stroke 0.15s;
}

.fc-edge-path:hover {
    stroke: #2563EB;
    stroke-width: 2.5;
}

.fc-edge.selected .fc-edge-path {
    stroke: #2563EB;
    stroke-width: 2.5;
}

/* Edge Label Badge */
.fc-edge-label-box {
    fill: #FFFFFF;
    stroke: #CBD5E1;
    stroke-width: 1;
    rx: 4;
    ry: 4;
    cursor: pointer;
}

.fc-edge:hover .fc-edge-label-box,
.fc-edge.selected .fc-edge-label-box {
    stroke: #2563EB;
    fill: #EFF6FF;
}

.fc-edge-label-text {
    font-family: 'Inter', sans-serif;
    font-size: 11px;
    font-weight: 700;
    fill: #2563EB;
    text-anchor: middle;
    dominant-baseline: central;
    cursor: pointer;
}

/* Temp Connection Line while dragging */
.fc-temp-edge {
    fill: none;
    stroke: #2563EB;
    stroke-width: 2.5;
    stroke-dasharray: 5, 5;
    pointer-events: none;
}

/* ── Inline Text Edit Overlay inside Canvas Viewport ── */
.flowchart-text-editor-input {
    position: absolute;
    background: #FFFFFF;
    border: 2px solid #2563EB;
    border-radius: 6px;
    padding: 6px 10px;
    font-family: 'Inter', -apple-system, sans-serif;
    font-size: 13px;
    font-weight: 600;
    color: #0F172A;
    text-align: center;
    box-shadow: 0 8px 24px rgba(37, 99, 235, 0.22), 0 2px 6px rgba(15, 23, 42, 0.1);
    z-index: 50;
    outline: none;
    resize: none;
    box-sizing: border-box;
    line-height: 1.4;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ── Canvas Empty State Overlay ── */
.flowchart-empty-state {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    pointer-events: none;
    transition: opacity 0.3s;
    user-select: none;
}

.flowchart-empty-icon {
    font-size: 2.25rem;
    margin-bottom: 0.5rem;
    opacity: 0.6;
}

.flowchart-empty-text {
    font-size: 0.92rem;
    font-weight: 600;
    color: #64748B;
}

.flowchart-empty-subtext {
    font-size: 0.78rem;
    color: #94A3B8;
    margin-top: 0.2rem;
}

/* ── Mobile Add Symbol Floating Button ── */
.flowchart-mobile-add-btn {
    display: none;
}

/* ── Toast Notifications ── */
.fc-toast-container {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.fc-toast {
    padding: 10px 18px;
    background: #0F172A;
    color: #FFFFFF;
    font-size: 0.85rem;
    font-weight: 600;
    border-radius: 9999px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.25);
    opacity: 0;
    transform: translateY(12px);
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.fc-toast.show {
    opacity: 1;
    transform: translateY(0);
}

.fc-toast.warning {
    background: #D97706;
}

.fc-toast.success {
    background: #15803D;
}

/* ── Responsive Behavior ── */
@media (max-width: 900px) {
    .flowchart-workspace-body {
        height: calc(100vh - 120px);
        min-height: 520px;
        width: 100%;
        margin: 0;
        border-left: none;
        border-right: none;
    }

    .flowchart-palette-panel {
        display: none;
    }

    .flowchart-mobile-add-btn {
        display: inline-flex;
    }

    .flowchart-page-subtitle {
        display: none;
    }
}

@media (max-width: 480px) {
    .flowchart-actions-toolbar {
        gap: 0.35rem;
    }
    .btn-flowchart-action span {
        display: none;
    }
    .btn-flowchart-action {
        padding: 0.45rem 0.55rem;
    }
}
