:root {
    --color-primary: #000000; /* ดำ */
    --color-secondary: #ffff00; /* เหลืองสด */
}


/* Panel Header Navigation */
.panel-header-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    background: linear-gradient(180deg, #ebf3fe 0%, #ffffff 10%);
    border-bottom: 0.1px solid #c9c9c938;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.nav-left {
    flex: 1;
}

.nav-title {
    font-size: 18px;
    font-weight: 700;
    margin: 0 0 8px 0;
    letter-spacing: 0.3px;
}

.nav-info {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}



.info-tag {
    font-size: 12px;
    font-weight: 600;
    opacity: 0.95;
}

.info-label {
    font-size: 12px;
    font-weight: 400;
    opacity: 0.9;
}

.nav-info-title .info-tag,
.nav-info-title .info-label {
    font-size: 16px;
    opacity: 100;
    color: var(--color-primary);
}

.nav-info-title .info-tag {
    font-weight: 600;
}

.btn-settings {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: #ffffff;
    padding: 4px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    margin-left: 8px;
    transition: all 0.2s;
    backdrop-filter: blur(10px);
}

.btn-settings:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.5);
    transform: scale(1.05);
}

.nav-right {
    display: flex;
    align-items: center;
}

.nav-controls {
    display: flex;
    gap: 12px;
    align-items: center;
}

.btn-status {
    padding: 8px 16px;
    border-radius: 6px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    backdrop-filter: blur(10px);
}

.btn-status.stopped {
    background: rgba(239, 83, 80, 0.9);
    color: #ffffff;
    border-color: rgba(255, 255, 255, 0.4);
}

.btn-status.stopped:hover {
    background: rgba(239, 83, 80, 1);
    box-shadow: 0 4px 12px rgba(239, 83, 80, 0.4);
    transform: translateY(-1px);
}

.btn-status.running {
    background: rgba(102, 187, 106, 0.9);
    color: #ffffff;
    border-color: rgba(255, 255, 255, 0.4);
}

.btn-status.running:hover {
    background: rgba(102, 187, 106, 1);
    box-shadow: 0 4px 12px rgba(102, 187, 106, 0.4);
    transform: translateY(-1px);
}

.btn-update {
    padding: 8px 24px;
    background: #ffffff;
    color: #667eea;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.btn-update:hover {
    background: #f0f0f0;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

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

.btn-menu {
    width: 36px;
    height: 36px;
    background: rgba(255, 255, 255, 0.2);
    color: #ffffff;
    border-radius: 6px;
    font-size: 20px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(10px);
}

.btn-menu:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.05);
}

/* Responsive Navigation */
@media (max-width: 1024px) {
    .panel-header-nav {
        flex-direction: column;
        gap: 12px;
        padding: 12px 16px;
    }

    .nav-left {
        width: 100%;
    }

    .nav-right {
        width: 100%;
    }

    .nav-controls {
        width: 100%;
        justify-content: flex-end;
    }

    .nav-info {
        font-size: 11px;
    }
}

@media (max-width: 768px) {
    .nav-title {
        font-size: 16px;
    }

    .nav-info {
        gap: 6px;
    }

    .info-tag,
    .info-label {
        font-size: 11px;
    }

    .btn-status,
    .btn-update {
        padding: 6px 12px;
        font-size: 12px;
    }

    .btn-menu {
        width: 32px;
        height: 32px;
        font-size: 18px;
    }

    /* Footer Responsive */
    .panel-footer {
        flex-direction: column;
        gap: 12px;
        padding: 12px 16px;
        min-height: auto;
    }

    .footer-left,
    .footer-right {
        width: 100%;
    }

    .footer-right {
        justify-content: flex-end;
    }

    .footer-left h3 {
        font-size: 14px;
    }

    .footer-info {
        font-size: 11px;
    }
}

/* Builder Container - Scoped styles */
.builder-container {
    display: flex;
    height: 600px;
    width: 100%;
    position: relative;
    background: #fafafa;
    overflow: hidden;
}

/* .builder-container * {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
} */

/* Left Panel Styles */
.left-panel {
    width: 350px;
    background: white;
    border-right: 1px solid #e0e0e0;
    display: flex;
    flex-direction: column;
    box-shadow: 2px 0 5px rgba(0, 0, 0, 0.05);
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid #e0e0e0;
}

.panel-header h2 {
    font-size: 15px;
    font-weight: 600;
    color: #333;
}

.count {
    color: #999;
    font-weight: normal;
}

.btn-add {
    padding: 6px 12px;
    background: white;
    border: 1px solid #0066cc;
    color: #0066cc;
    border-radius: 3px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s;
}

.btn-add:hover {
    background: #0066cc;
    color: white;
}

.warning-box {
    display: flex;
    gap: 8px;
    padding: 10px 12px;
    background: #fff8e1;
    border-bottom: 1px solid #ffe082;
    border-left: 3px solid #ffa726;
}

.warning-icon {
    color: #f57c00;
    font-size: 16px;
}

.warning-text {
    flex: 1;
    font-size: 10px;
    color: #666;
}

.warning-subtext {
    color: #ff6600;
    margin-top: 2px;
    font-weight: 500;
}

.segments-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.segment-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    margin-bottom: 6px;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    cursor: move;
    transition: all 0.2s;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    position: relative;
}

.segment-item:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    border-color: #ccc;
}

/* Segment item with connection */
.segment-item.has-connection {
    border-color: #66BB6A;
    background: #f1f8f4;
}

.segment-item.has-connection::after {
    content: '✓';
    position: absolute;
    top: 8px;
    right: 8px;
    width: 18px;
    height: 18px;
    background: #66BB6A; 
    color: white; 
    border-radius: 50%; 
    display: flex; 
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    z-index: 3;
}

.segment-badge {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    font-size: 11px;
}

.badge-red {
    background: #e53935;
}

.badge-blue {
    background: #1e88e5;
}

.badge-green {
    background: #4caf50;
}

.badge-white {
    background: #ffffff;
    color: #333333;
    border: 2px solid #e0e0e0;
}

.segment-info {
    flex: 1;
    min-width: 0;
}

.segment-type {
    font-size: 9px;
    color: #999;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.segment-name {
    font-size: 12px;
    color: #333;
    font-weight: 500;
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.segment-count {
    font-size: 13px;
    font-weight: 600;
    color: #333;
    min-width: 50px;
    text-align: right;
}

.segment-count.error {
    color: #e53935;
}

.segment-actions {
    display: flex;
    gap: 8px;
}

.btn-icon {
    background: #f5f5f5;
    border: 1px solid #ddd;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    color: #666;
    padding: 6px 8px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
}

.btn-icon:hover {
    background: #e0e0e0;
    color: #333;
    border-color: #999;
}

.btn-connect-source {
    background: #e8f5e9;
    border-color: #4caf50;
    color: #2e7d32;
}

.btn-connect-source:hover {
    background: #4caf50;
    color: white;
    border-color: #2e7d32;
}

.btn-edit {
    background: #e3f2fd;
    border-color: #1e88e5;
    color: #1565c0;
    border-radius: 8px;
}

.btn-edit:hover {
    background: #1e88e5;
    color: white;
    border-color: #1565c0;
    border-radius: 8px;
}

.btn-delete {
    background: #ffebee;
    border-color: #e53935;
    color: #c62828;
    border-radius: 8px;
}

.btn-delete:hover {
    background: #e53935;
    color: white;
    border-color: #c62828;
    border-radius: 8px;
}

/* Join Sidebar Styles */
.join-sidebar {
    width: 60px;
    background: white;
    border-left: 1px solid #e0e0e0;
    display: flex;
    flex-direction: column;
    box-shadow: -2px 0 5px rgba(0, 0, 0, 0.05);
}

.join-sidebar-header {
    padding: 8px 4px;
    border-bottom: 1px solid #e0e0e0;
    text-align: center;
}

.join-sidebar-header h3 {
    font-size: 10px;
    font-weight: 600;
    color: #333;
    margin: 0;
    line-height: 1.3;
}

.join-types-list {
    padding: 8px 4px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: center;
}

.join-type-item {
    width: 40px;
    height: 40px;
    background: white;
    border: 1.5px solid #e0e0e0;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: move;
    transition: all 0.2s;
    padding: 6px;
    position: relative;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

.btn-join-connect {
    position: absolute;
    bottom: -8px;
    right: -8px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #4caf50;
    color: white;
    border: 2px solid white;
    cursor: pointer;
    font-size: 12px;
    line-height: 1;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 0;
    margin: 0;
    box-sizing: border-box;
    transition: all 0.2s;
    z-index: 12;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    text-align: center;
}

.join-type-item:hover .btn-join-connect {
    display: flex;
}

.btn-join-connect:hover {
    background: #388e3c;
    transform: scale(1.1);
}

.join-type-item:hover {
    border-color: #1e88e5;
    box-shadow: 0 2px 8px rgba(30, 136, 229, 0.2);
    transform: scale(1.05);
}

.join-type-item:active {
    transform: scale(0.98);
}

.join-type-item.dragging {
    opacity: 0.5;
}

.join-icon {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    user-select: none;
    -webkit-user-drag: none;
    pointer-events: none;
}

/* Right Panel Styles */
.right-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #fafafa;
}

/* Panel Footer */
.panel-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 10px;
    background: linear-gradient(0deg, #f8f9fa 0%, #ffffff 100%);
    border-top: 1px solid #e0e0e0;
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.05);
    min-height: 40px;
    flex-shrink: 0;
}

.footer-left {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.footer-left h3 {
    font-size: 16px;
    font-weight: 600;
    color: #333;
    margin: 0;
}

.footer-info {
    font-size: 12px;
    color: #666;
    font-style: italic;
}

.footer-right {
    display: flex;
    gap: 12px;
    align-items: center;
}

.btn-auto-layout {
    padding: 6px 16px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    color: white;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 6px;
    box-shadow: 0 2px 4px rgba(102, 126, 234, 0.3);
}

.btn-auto-layout:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(102, 126, 234, 0.5);
}

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

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

.canvas {
    flex: 1 1 auto;
    position: relative;
    overflow-x: hidden;  /* ซ่อน scrollbar แนวนอน */
    overflow-y: auto;    /* แสดง scrollbar แนวตั้งเมื่อจำเป็น */
    padding: 60px;
    background-color: #fafafa;
    background-image:
        linear-gradient(rgba(0, 0, 0, 0.05) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0, 0, 0, 0.05) 1px, transparent 1px);
    background-size: 10px 10px;
    min-height: 0;
}

/* จุด Origin (0,0) - จุดแดงที่ X=0, Y=0 */
.canvas-origin-marker {
    position: absolute;
    left: calc(50% - 8px);
    top: calc(50% - 8px);
    width: 10px;
    height: 10px;
    background-color: #57575750;
    border: 3px solid #ffffff50;
    border-radius: 50%;
    z-index: 10;
    pointer-events: none;
    box-shadow: 0 0 0 2px #f5f3f3, 0 0 8px rgba(12, 12, 12, 0.4);
}

/* แสดงพิกัด X, Y เมื่อ hover */
.canvas-coordinates {
    position: fixed;
    top: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.85);
    color: #ffffff;
    padding: 8px 14px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    font-family: 'Courier New', monospace;
    z-index: 1000;
    pointer-events: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.2);
    opacity: 0;
    transition: opacity 0.2s ease;
}

.canvas:hover .canvas-coordinates {
    opacity: 1;
}

/* Custom scrollbar styles for canvas - แนวตั้งอย่างเดียว */
.canvas::-webkit-scrollbar {
    width: 12px;
    height: 0px;  /* ซ่อน scrollbar แนวนอน */
}

.canvas::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.canvas::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 10px;
    border: 2px solid #f1f1f1;
}

.canvas::-webkit-scrollbar-thumb:hover {
    background: #555;
}

.canvas::-webkit-scrollbar-corner {
    background: #f1f1f1;
}

.connections-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    min-width: 3000px;
    min-height: 3000px;
    pointer-events: none;
    z-index: 1;
    overflow: visible;
}

.canvas-node {
    position: absolute;
    z-index: 2;
}

.segment-node {
    background: white;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    padding: 4px;
    width: 80px;
    height: 80px;
    cursor: grab;
    transition: all 0.2s;
    user-select: none;
    -webkit-user-select: none;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.segment-node:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    border-color: #ccc;
}

.segment-node.active {
    border-color: #1e88e5;
    box-shadow: 0 0 0 3px rgba(30, 136, 229, 0.2);
}

/* Segment Node Connection States */
.segment-node.connections-0 {
    border-color: #e0e0e0;
}

.segment-node.connections-1 {
    border-color: #66BB6A;
    box-shadow: 0 0 0 2px rgba(102, 187, 106, 0.2);
}

/* Segment Connection Indicator - ซ่อนไว้ */
.segment-connection-indicator {
    display: none !important;
}

.node-badge {
    position: absolute;
    top: -10px;
    left: 8px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    font-size: 11px;
    z-index: 5;
}

.node-content {
    text-align: center;
}

.node-image {
    width: 50%;
    height: 50%;
    object-fit: contain;
    display: block;
    pointer-events: none;
    user-select: none;
}

.join-node-image {
    width: 50%;
    height: 50%;
    object-fit: contain;
    display: block;
    pointer-events: none;
    user-select: none;
}

.node-label {
    font-size: 7px;
    color: #999;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-bottom: 2px;
}

.node-name {
    font-size: 9px;
    color: #333;
    font-weight: 600;
}

.node-name-display {
    position: absolute;
    bottom: -20px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 10px;
    color: #333;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.9);
    padding: 2px 6px;
    border-radius: 4px;
    white-space: nowrap;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    margin-bottom: 3px;
    line-height: 1.2;
}

.node-count {
    position: absolute;
    bottom: -18px;
    left: 50%;
    transform: translateX(-50%);
    text-align: center;
    font-size: 9px;
    font-weight: bold;
    color: #1e88e5;
    background: white;
    padding: 2px 6px;
    border-radius: 3px;
    border: 1px solid #e0e0e0;
    white-space: nowrap;
}

.join-node {
    background: white;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    padding: 4px;
    width: 80px;
    height: 80px;
    cursor: grab;
    transition: all 0.2s;
    user-select: none;
    -webkit-user-select: none;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.join-node:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    border-color: #ccc;
}

.join-node.active {
    border-color: #1e88e5;
    box-shadow: 0 0 0 3px rgba(30, 136, 229, 0.2);
}

/* Join Node Connection States */
.join-node.connections-0 {
    border-color: #e0e0e0;
}

.join-node.connections-1 {
    border-color: #FFA726;
    box-shadow: 0 0 0 2px rgba(255, 167, 38, 0.2);
}

.join-node.connections-2 {
    border-color: #66BB6A;
    box-shadow: 0 0 0 2px rgba(102, 187, 106, 0.2);
}

/* Connection Indicator - ซ่อนไว้ */
.connection-indicator {
    display: none !important;
}

/* Connection Points on Top of Join Node */
.connection-points.top {
    position: absolute;
    top: -6px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 12px;
    z-index: 8;
}

.connection-point {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #B8B8B8;
    border: 1.5px solid white;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    transition: all 0.2s;
    cursor: pointer;
    position: relative;
    z-index: 9;
}

.connection-point:hover {
    background: #5DADE2;
    transform: scale(1.2);
}

.connection-point.connected {
    background: #66BB6A;
}

/* Labels for connection points */
.connection-point::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: white;
}

.join-node:hover .connection-point:not(.connected) {
    background: #5DADE2;
}

/* Animate connection points when connecting */
.connecting ~ .canvas .connection-point:not(.connected) {
    animation: pulse-connection 1s infinite;
}

@keyframes pulse-connection {
    0%, 100% {
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    }
    50% {
        box-shadow: 0 0 0 4px rgba(93, 173, 226, 0.4);
    }
}

.venn-diagram {
    position: relative;
    height: 30px;
    display: none;
    align-items: center;
    justify-content: center;
}

.venn-circle {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    position: absolute;
    opacity: 0.5;
}

.venn-circle.left {
    background: #bbb;
    left: 6px;
}

.venn-circle.right {
    background: #bbb;
    right: 6px;
}

/* join-label ถูกแทนที่ด้วย node-count */

.connect-node-btn {
    position: absolute;
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%);
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #1e88e5;
    color: white;
    border: 2px solid white;
    cursor: pointer;
    font-size: 12px;
    line-height: 1;
    display: none;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    z-index: 15;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    pointer-events: auto;
}

.delete-node-btn {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #e53935;
    color: white;
    border: none;
    cursor: pointer;
    font-size: 12px;
    line-height: 1;
    display: none;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    z-index: 15;
}

.join-node:hover .delete-node-btn,
.segment-node:hover .delete-node-btn,
.join-node:hover .connect-node-btn,
.segment-node:hover .connect-node-btn {
    display: flex;
}

.connect-node-btn:hover {
    background: #1565c0;
    transform: translateX(-50%) scale(1.1);
}

.delete-node-btn:hover {
    background: #c62828;
    transform: scale(1.1);
}

.canvas-node.connecting {
    box-shadow: 0 0 0 3px #1e88e5;
    animation: pulse 1s infinite;
}

.segment-item.connecting,
.join-type-item.connecting {
    box-shadow: 0 0 0 3px #4caf50;
    animation: pulse-green 1s infinite;
}

@keyframes pulse {
    0%, 100% {
        box-shadow: 0 0 0 3px rgba(30, 136, 229, 0.5);
    }
    50% {
        box-shadow: 0 0 0 6px rgba(30, 136, 229, 0.3);
    }
}

@keyframes pulse-green {
    0%, 100% {
        box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.5);
    }
    50% {
        box-shadow: 0 0 0 6px rgba(76, 175, 80, 0.3);
    }
}

.calculate-section {
    position: absolute;
    text-align: center;
}

.result-display {
    background: white;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    padding: 20px;
    font-size: 32px;
    font-weight: bold;
    color: #333;
    margin-bottom: 16px;
    display: inline-block;
    min-width: 120px;
}

.btn-calculate {
    padding: 12px 32px;
    background: #1e88e5;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.btn-calculate:hover {
    background: #1976d2;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
    transform: translateY(-1px);
}

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

.preview-text {
    margin-top: 16px;
    font-size: 12px;
    color: #999;
    line-height: 1.5;
}

/* Scrollbar Styles */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #999;
}

/* Connection Lines */
.connection-line {
    stroke: #B8B8B8;
    stroke-width: 2;
    fill: none;
    stroke-linejoin: miter;
    stroke-linecap: square;
    transition: all 0.3s ease;
}

.connection-line.active {
    stroke: #5DADE2;
    stroke-width: 2.5;
}

.connection-line:hover {
    stroke: #5DADE2;
    stroke-width: 2.5;
    cursor: pointer;
}

/* Connection Delete Button */
.connection-delete-btn {
    opacity: 0;
    transition: opacity 0.2s ease;
}

.connection-delete-btn:hover {
    opacity: 1 !important;
}

/* Show delete button when hovering near the line */
svg:hover .connection-delete-btn {
    opacity: 0.8;
}

/* Drag and Drop */
.segment-item.dragging {
    opacity: 0.5;
}

.canvas.drag-over {
    background: #e3f2fd;
}

/* Modal Styles - Slide from Right */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9999;
    align-items: flex-start;
    justify-content: flex-end;
    backdrop-filter: blur(2px);
}

.modal-container {
    background: white;
    border-radius: 0;
    max-width: 800px;
    width: 100%;
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.15);
    animation: modalSlideInRight 0.3s ease-out;
}

@keyframes modalSlideInRight {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Close animation */
.modal-overlay.closing .modal-container {
    animation: modalSlideOutRight 0.3s ease-out;
}

@keyframes modalSlideOutRight {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(100%);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px;
    color: var(--color-secondary);
    background: var(--color-primary);
}

.modal-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.modal-icon {
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-title {
    font-size: 20px;
    font-weight: 600;
    color: var(--color-secondary);
    margin: 0;
}

/* .modal-close {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: none;
    background: #b6b5b5;
    border-color: #e53935;
    color: #ffffff;
    font-size: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.modal-close:hover {
    background: rgba(248, 107, 107, 0.3);
    transform: scale(1.1);
} */

.modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    background: #fafafa;
    position: relative;
}

.modal-loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(2px);
}

.modal-loading-content {
    text-align: center;
}

.modal-loading-content .spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #1e88e5;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 16px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.modal-loading-content .loading-text {
    color: #666;
    font-size: 14px;
    font-weight: 500;
    margin: 0;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 12px 12px 12px 40px;
    border-top: 1px solid #e0e0e0;
    background: white;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
}

.btn-cancel {
    padding: 8px 20px;
    background: white;
    border: 1px solid #ddd;
    color: #666;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-cancel:hover {
    background: #f5f5f5;
    border-color: #bbb;
}


/* Segment Section */
.segment-section {
    margin-bottom: 32px;
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.section-title {
    font-size: 16px;
    font-weight: 600;
    color: #333;
    margin: 0 0 16px 0;
}

.segment-options {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 16px;
}

.segment-option-card {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 10px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    background: white;
}

.segment-option-card:hover {
    border-color: var(--color-primary);
    box-shadow: 0 2px 8px rgba(30, 136, 229, 0.1);
}

.segment-option-card.active {
    border-color: var(--color-primary);
    background: #f8f9fa;
    box-shadow: 0 2px 8px rgba(30, 136, 229, 0.2);
}

.option-icon {
    width: 40px;
    height: 40px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
    border: 1px solid var(--color-primary);
    color: var(--color-primary);
    background: #fff;
    transition: all 0.3s;
}

.segment-option-card.active .option-icon {
    background: var(--color-primary);
    border: 1px solid var(--color-primary);
    color: var(--color-secondary);
}

.option-content {
    flex: 1;
}

.option-title {
    font-size: 14px;
    font-weight: 600;
    color: #333;
    margin: 0 0 4px 0;
}

.option-description {
    font-size: 12px;
    color: #666;
    margin: 0;
    line-height: 1.4;
}

/* Form Styles */
.form-section {
    margin-bottom: 24px;
}
/*
.form-label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: #333;
    margin-bottom: 8px;
}

.form-description {
    font-size: 12px;
    color: #666;
    margin: 4px 0 16px 0;
} */


.schedule-card {
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    padding: 16px;
    transition: all 0.3s;
    cursor: pointer;
    background: #fff;
}

.schedule-card:hover {
    border-color: var(--color-primary);
}

.schedule-card.active {
    border-color: var(--color-primary);
    background: #f4f4f4;
}

.schedule-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.schedule-header input[type="radio"] {
    margin: 0;
}

.schedule-header label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    flex: 1;
}

.schedule-icon {
    font-size: 24px;
}

.schedule-header h4 {
    font-size: 16px;
    font-weight: 600;
    color: #333;
    margin: 0;
}

.schedule-description {
    font-size: 12px;
    color: #666;
    margin: 0 0 12px 0;
    line-height: 1.4;
}

.schedule-details {
    background: #f8f9fa;
    border-radius: 6px;
    padding: 12px;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    font-size: 12px;
}

.detail-label {
    color: #666;
    font-weight: 500;
}

.detail-value {
    color: #333;
    text-align: right;
}

.wizard-icon {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    background: #e3f2fd;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.form-group {
    margin-bottom: 20px;
}

.form-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    transition: all 0.2s;
}

.form-input:focus {
    outline: none;
    border-color: #1e88e5;
    box-shadow: 0 0 0 3px rgba(30, 136, 229, 0.1);
}

/* Modal Responsive */
@media (max-width: 768px) {
    .modal-container {
        max-width: 100%;
        width: 100%;
    }

    .modal-body {
        padding: 16px;
    }

    .modal-footer {
        padding: 16px;
    }

    .segment-options {
        grid-template-columns: 1fr;
    }

    .schedule-options {
        grid-template-columns: 1fr;
    }
}
