* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #ec4899 0%, #f472b6 50%, #f9a8d4 100%);
    min-height: 100vh;
    padding: 20px;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    overflow: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: none;
}

@media (max-width: 768px) {
    body {
        padding: 10px;
    }
}

@media (max-width: 480px) {
    body {
        padding: 5px;
    }
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: calc(100vh - 40px);
}

@media (max-width: 768px) {
    .container {
        height: calc(100vh - 20px);
        border-radius: 15px;
    }
}

@media (max-width: 480px) {
    .container {
        height: calc(100vh - 10px);
        border-radius: 10px;
    }
}

.header {
    background: linear-gradient(135deg, #db2777 0%, #ec4899 50%, #f472b6 100%);
    color: white;
    padding: 20px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
    box-shadow: 0 4px 15px rgba(236, 72, 153, 0.3);
}

.header-title {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

.header h1 {
    font-size: 2em;
    font-weight: 700;
    margin: 0;
}

@media (max-width: 768px) {
    .header {
        padding: 15px 20px;
    }
    
    .header-title {
        width: 100%;
        justify-content: space-between;
        gap: 10px;
    }
    
    .header h1 {
        font-size: 1.4em;
    }
}

.controls {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

@media (max-width: 768px) {
    .controls {
        width: 100%;
        justify-content: space-between;
        gap: 8px;
    }
    
    .controls .btn {
        flex: 1;
        min-width: 0;
    }
}

@media (max-width: 480px) {
    .controls {
        gap: 6px;
    }
    
    .controls .btn {
        flex: 1;
        min-width: 50px;
    }
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    white-space: nowrap;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2);
}

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

.btn-icon {
    font-size: 1.2em;
    line-height: 1;
}

.btn-text {
    line-height: 1;
}

@media (max-width: 768px) {
    .btn {
        padding: 10px 16px;
        font-size: 14px;
        gap: 6px;
    }
    
    .btn-text {
        display: none;
    }
    
    .btn-icon {
        font-size: 1.4em;
    }
}

@media (max-width: 480px) {
    .btn {
        padding: 10px 12px;
        font-size: 12px;
    }
    
    .btn-icon {
        font-size: 1.3em;
    }
}

.btn-primary {
    background: white;
    color: #ec4899;
    font-weight: 600;
}

.btn-primary:hover {
    background: #fdf2f8;
    color: #db2777;
    box-shadow: 0 4px 12px rgba(236, 72, 153, 0.3);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.25);
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.5);
    backdrop-filter: blur(10px);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.35);
    border-color: white;
}

.btn-success {
    background: #10b981;
    color: white;
}

.btn-success:hover {
    background: #059669;
}

.btn-info {
    background: rgba(255, 255, 255, 0.25);
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.5);
    backdrop-filter: blur(10px);
}

.btn-info:hover {
    background: rgba(255, 255, 255, 0.35);
    border-color: white;
}

.btn-info-toggle {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.4);
    padding: 8px 16px;
    font-size: 14px;
    border-radius: 20px;
    backdrop-filter: blur(5px);
}

.btn-info-toggle:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.6);
}

.btn-info-toggle.active {
    background: rgba(255, 255, 255, 0.4);
    border-color: white;
}

@media (max-width: 768px) {
    .btn-info-toggle {
        padding: 6px 12px;
        font-size: 13px;
    }
    
    .btn-info-toggle .info-text {
        display: none;
    }
    
    .btn-info-toggle .info-icon {
        font-size: 1.2em;
    }
}

.btn.active {
    background: #fce7f3;
    color: #db2777;
    border: 2px solid white;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% {
        box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    }
    50% {
        box-shadow: 0 4px 6px rgba(236, 72, 153, 0.5);
    }
}

.info {
    padding: 15px 30px;
    background: linear-gradient(to right, #fdf2f8, #ffffff);
    border-bottom: 2px solid #fce7f3;
    box-shadow: 0 2px 4px rgba(236, 72, 153, 0.1);
    max-height: 500px;
    overflow: hidden;
    transition: max-height 0.4s ease, padding 0.4s ease, opacity 0.3s ease;
    opacity: 1;
}

.info.hidden {
    max-height: 0;
    padding: 0 30px;
    opacity: 0;
    border-bottom: none;
}

.info-content {
    transition: transform 0.3s ease;
}

.info-content p {
    color: #495057;
    font-size: 14px;
    font-weight: 600;
    margin: 0 0 10px 0;
}

.info-content ul {
    margin: 0;
    padding-left: 20px;
    list-style-type: none;
}

.info-content li {
    color: #495057;
    font-size: 13px;
    line-height: 1.8;
    margin-bottom: 6px;
    position: relative;
    padding-left: 15px;
}

.info-content li:before {
    content: "▸";
    position: absolute;
    left: 0;
    color: #ec4899;
    font-weight: bold;
}

@media (max-width: 768px) {
    .info {
        padding: 12px 20px;
    }
    
    .info.hidden {
        padding: 0 20px;
    }
    
    .info-content p {
        font-size: 13px;
    }
    
    .info-content li {
        font-size: 12px;
        line-height: 1.6;
        margin-bottom: 5px;
    }
}

@media (max-width: 480px) {
    .info {
        padding: 10px 15px;
    }
    
    .info.hidden {
        padding: 0 15px;
    }
    
    .info-content p {
        font-size: 12px;
    }
    
    .info-content li {
        font-size: 11px;
    }
}

.canvas-wrapper {
    flex: 1;
    position: relative;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #f5f5f5;
}

.canvas-container {
    flex: 1;
    overflow: auto;
    position: relative;
    background: #fafafa;
    cursor: default;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

@media (max-width: 768px) {
    .canvas-container {
        touch-action: none;
    }
}

/* Custom scrollbar */
.canvas-container::-webkit-scrollbar {
    width: 12px;
    height: 12px;
}

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

.canvas-container::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 6px;
}

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

@media (max-width: 768px) {
    .canvas-container::-webkit-scrollbar {
        width: 8px;
        height: 8px;
    }
}

@media (max-width: 480px) {
    .canvas-container::-webkit-scrollbar {
        width: 6px;
        height: 6px;
    }
}

.canvas-scroll {
    width: 5000px;
    height: 5000px;
    position: relative;
    min-width: 100%;
    min-height: 100%;
}

#svgCanvas {
    width: 5000px;
    height: 5000px;
    display: block;
    position: absolute;
    top: 0;
    left: 0;
}

.zoom-controls {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 5px;
    background: white;
    padding: 8px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.zoom-btn {
    width: 36px;
    height: 36px;
    border: 2px solid #ddd;
    background: white;
    border-radius: 6px;
    font-size: 20px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    color: #333;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.zoom-btn:hover {
    background: #ec4899;
    color: white;
    border-color: #ec4899;
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(236, 72, 153, 0.3);
}

.zoom-btn:active {
    transform: scale(0.95);
}

.zoom-level {
    text-align: center;
    font-size: 12px;
    font-weight: 600;
    color: #666;
    padding: 4px 0;
    border-top: 1px solid #eee;
    margin-top: 4px;
}

@media (max-width: 768px) {
    .zoom-controls {
        top: 5px;
        right: 5px;
        padding: 6px;
        gap: 4px;
    }
    
    .zoom-btn {
        width: 32px;
        height: 32px;
        font-size: 18px;
    }
    
    .zoom-level {
        font-size: 11px;
        padding: 3px 0;
    }
}

@media (max-width: 480px) {
    .zoom-controls {
        padding: 5px;
        gap: 3px;
    }
    
    .zoom-btn {
        width: 28px;
        height: 28px;
        font-size: 16px;
        border-width: 1.5px;
    }
    
    .zoom-level {
        font-size: 10px;
    }
}

.canvas-container.panning {
    cursor: grab !important;
}

.canvas-container.panning:active {
    cursor: grabbing !important;
}

.canvas-container.panning .node {
    cursor: grab !important;
}

.node {
    cursor: move;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

.node-rect {
    fill: white;
    stroke: #ec4899;
    stroke-width: 3;
    rx: 12;
    ry: 12;
    filter: drop-shadow(0 2px 4px rgba(236, 72, 153, 0.2));
    transition: stroke 0.2s ease, 
                stroke-width 0.2s ease, 
                filter 0.2s ease, 
                fill 0.2s ease;
    pointer-events: all;
}

.node-rect:hover {
    stroke: #f472b6;
    stroke-width: 4;
    filter: drop-shadow(0 4px 12px rgba(236, 72, 153, 0.4));
    fill: #fdf2f8;
}

.node.selected .node-rect {
    stroke: #db2777;
    stroke-width: 4;
    fill: #fce7f3;
    filter: drop-shadow(0 4px 8px rgba(219, 39, 119, 0.4));
}

.node.selected .node-rect:hover {
    stroke: #db2777;
    stroke-width: 4;
    fill: #f9a8d4;
    filter: drop-shadow(0 4px 12px rgba(219, 39, 119, 0.5));
}

.node-text {
    fill: #333;
    font-size: 16px;
    font-weight: 600;
    text-anchor: middle;
    dominant-baseline: middle;
    pointer-events: none;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    user-select: none;
}

@media (max-width: 768px) {
    .node-rect {
        stroke-width: 4;
    }
    
    .node-text {
        font-size: 15px;
    }
}

@media (max-width: 480px) {
    .node-rect {
        stroke-width: 3;
    }
    
    .node-text {
        font-size: 14px;
    }
}

.connection {
    stroke: #666;
    stroke-width: 2;
    fill: none;
    marker-end: url(#arrowhead);
    transition: stroke 0.2s ease, stroke-width 0.2s ease, opacity 0.2s ease;
    cursor: pointer;
    opacity: 0.8;
}

.connection:hover {
    stroke: #ec4899;
    stroke-width: 3;
    opacity: 1;
}

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
}

.modal-content {
    background-color: white;
    margin: 15% auto;
    padding: 30px;
    border-radius: 15px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    line-height: 20px;
}

.close:hover {
    color: #000;
}

.modal-content h2 {
    margin-bottom: 20px;
    color: #333;
}

#nodeTextInput {
    width: 100%;
    padding: 12px;
    font-size: 16px;
    border: 2px solid #ddd;
    border-radius: 8px;
    margin-bottom: 20px;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

#nodeTextInput:focus {
    outline: none;
    border-color: #ec4899;
    box-shadow: 0 0 0 3px rgba(236, 72, 153, 0.1);
}

.modal-buttons {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.modal-buttons .btn {
    padding: 10px 20px;
}

.modal-buttons .btn-secondary {
    background: #f5f5f5;
    color: #333;
    border: 2px solid #ddd;
}

.modal-buttons .btn-secondary:hover {
    background: #e5e5e5;
    border-color: #ccc;
}

.modal-content {
    background-color: white;
    margin: 15% auto;
    padding: 30px;
    border-radius: 15px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: slideDown 0.3s ease;
}

@media (max-width: 768px) {
    .modal-content {
        margin: 25% auto;
        padding: 25px 20px;
        width: 85%;
    }
    
    .modal-content h2 {
        font-size: 1.3em;
    }
    
    #nodeTextInput {
        padding: 10px;
        font-size: 15px;
    }
    
    .modal-buttons .btn {
        padding: 10px 18px;
        font-size: 14px;
    }
    
    .modal-buttons .btn .btn-text {
        display: inline;
    }
}

@media (max-width: 480px) {
    .modal-content {
        margin: 20% auto;
        padding: 20px 15px;
        width: 95%;
        max-width: none;
    }
    
    .modal-content h2 {
        font-size: 1.2em;
        margin-bottom: 15px;
    }
    
    #nodeTextInput {
        padding: 10px;
        font-size: 16px;
        margin-bottom: 15px;
    }
    
    .modal-buttons {
        flex-direction: row;
        gap: 8px;
    }
    
    .modal-buttons .btn {
        flex: 1;
    }
}

/* Touch improvements for mobile */
@media (hover: none) and (pointer: coarse) {
    .node {
        cursor: default;
        -webkit-user-select: none;
        user-select: none;
        touch-action: none;
        pointer-events: all;
    }
    
    .node-rect {
        stroke-width: 4;
        pointer-events: all;
        touch-action: none;
    }
    
    .btn:hover {
        transform: none;
        box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    }
    
    .btn:active {
        transform: scale(0.95);
        opacity: 0.9;
    }
    
    .zoom-btn:hover {
        transform: none;
        background: white;
        color: #333;
        border-color: #ddd;
    }
    
    .zoom-btn:active {
        transform: scale(0.9);
        background: #ec4899;
        color: white;
        border-color: #ec4899;
    }
    
    .connection {
        stroke-width: 4;
    }
    
    .connection:hover {
        stroke-width: 4;
        stroke: #666;
    }
    
    /* Larger touch targets on mobile */
    .node-rect {
        stroke-width: 4;
        rx: 15;
        ry: 15;
    }
    
    /* Improve node tap feedback */
    .node.selected .node-rect {
        stroke-width: 5;
    }
}

/* Prevent text selection on mobile during interactions */
@media (max-width: 768px) {
    body {
        -webkit-user-select: none;
        -moz-user-select: none;
        -ms-user-select: none;
        user-select: none;
    }
    
    input, textarea {
        -webkit-user-select: text;
        -moz-user-select: text;
        -ms-user-select: text;
        user-select: text;
    }
}

/* Smooth animations */
.node, .connection, .btn, .zoom-btn, .info {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Improved visual hierarchy */
.header {
    z-index: 10;
    position: relative;
}

.canvas-wrapper {
    z-index: 1;
}

.zoom-controls {
    z-index: 100;
    backdrop-filter: blur(10px);
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(236, 72, 153, 0.1);
}

/* Better hover states for desktop */
@media (hover: hover) and (pointer: fine) {
    .btn:hover {
        transform: translateY(-2px);
        box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2);
    }
    
    .zoom-btn:hover {
        background: #ec4899;
        color: white;
        border-color: #ec4899;
        transform: scale(1.1);
        box-shadow: 0 4px 12px rgba(236, 72, 153, 0.3);
    }
}

/* Mobile Context Menu - REMOVED (fokus pada drag) */

/* Toast Notification - Removed (tidak diperlukan tanpa context menu) */

/* Visual feedback for dragging on mobile */
.node.dragging {
    opacity: 0.9;
    filter: drop-shadow(0 12px 20px rgba(236, 72, 153, 0.6));
    transform: scale(1.05);
    transition: none !important;
}

.node.dragging .node-rect {
    stroke: #db2777;
    stroke-width: 5;
    fill: #fce7f3;
    animation: dragPulse 0.5s ease-in-out infinite alternate;
}

@keyframes dragPulse {
    from {
        filter: drop-shadow(0 4px 8px rgba(219, 39, 119, 0.4));
    }
    to {
        filter: drop-shadow(0 8px 16px rgba(219, 39, 119, 0.6));
    }
}

/* Prevent scrolling when dragging nodes on mobile */
@media (max-width: 768px) {
    .canvas-container.node-dragging {
        overflow: hidden !important;
        touch-action: none !important;
        -webkit-overflow-scrolling: auto;
        overscroll-behavior: none;
    }
    
    /* Extra visual feedback on mobile */
    .node.dragging {
        transform: scale(1.08);
        z-index: 9999;
    }
    
    /* Ensure nodes can be touched and dragged */
    .node {
        touch-action: none;
        pointer-events: all;
    }
    
    .node-rect {
        pointer-events: all;
        touch-action: none;
    }
    
    .node-text {
        pointer-events: none;
        touch-action: none;
    }
    
    /* SVG Canvas should allow touch */
    #svgCanvas {
        touch-action: none;
    }
}

/* Ripple effect for mobile touch */
@keyframes ripple {
    0% {
        transform: scale(0);
        opacity: 1;
    }
    100% {
        transform: scale(4);
        opacity: 0;
    }
}

.node-rect.touched {
    animation: none;
}

/* Mobile feedback removed - fokus pada drag */

/* Show/Hide instructions based on device */
.mobile-instructions {
    display: none;
}

@media (max-width: 768px) {
    .desktop-instructions {
        display: none;
    }
    
    .mobile-instructions {
        display: block;
    }
}

/* Floating Action Button (FAB) */
.fab {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #ec4899 0%, #f472b6 100%);
    color: white;
    border: none;
    box-shadow: 0 8px 20px rgba(236, 72, 153, 0.4);
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 999;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    -webkit-tap-highlight-color: transparent;
}

.fab:active {
    transform: scale(0.9);
    box-shadow: 0 4px 12px rgba(236, 72, 153, 0.6);
}

.fab .fab-icon {
    font-size: 32px;
    line-height: 1;
    font-weight: 300;
}

@media (max-width: 768px) {
    .fab {
        display: flex;
    }
}

@media (max-width: 480px) {
    .fab {
        width: 56px;
        height: 56px;
        bottom: 15px;
        right: 15px;
    }
    
    .fab .fab-icon {
        font-size: 28px;
    }
}

/* FAB Animation */
@keyframes fabPulse {
    0%, 100% {
        box-shadow: 0 8px 20px rgba(236, 72, 153, 0.4);
    }
    50% {
        box-shadow: 0 8px 30px rgba(236, 72, 153, 0.6);
    }
}

.fab:hover {
    animation: fabPulse 2s infinite;
    transform: scale(1.05);
}
