:root {
    --primary-color: #0078D4;
    --primary-hover: #106EBE;
    --bg-color: #f0f0f0;
    --canvas-bg: #ffffff;
    --ribbon-bg: #ffffff;
    --border-color: #ccc;
    --node-bg: #fdfdfd;
    --node-border: #999;
    --node-shadow: 0 4px 8px rgba(0,0,0,0.1);
    --start-node-bg: #e8f5e9;
    --start-node-border: #4CAF50;
    --selected-node-border: #0078D4;
    --text-color: #333;
    --modal-overlay-bg: rgba(0,0,0,0.6);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body, html {
    height: 100%;
    width: 100%;
    overflow: hidden;
    background-color: var(--bg-color);
    color: var(--text-color);
}

#app-container {
    display: flex;
    flex-direction: column;
    height: 100%;
}

/* Ribbon */
#ribbon {
    background-color: var(--ribbon-bg);
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

#ribbon-tabs {
    display: flex;
    padding: 0 10px;
    border-bottom: 1px solid var(--border-color);
}

.tab-button {
    padding: 10px 15px;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 14px;
    border-bottom: 2px solid transparent;
}

.tab-button.active {
    border-bottom-color: var(--primary-color);
    font-weight: 600;
}

#ribbon-content {
    padding: 5px;
    display: flex;
    flex-wrap: wrap;
}

.tab-content {
    display: none;
}
.tab-content.active {
    display: flex;
}

.ribbon-group {
    display: flex;
    padding: 0 10px;
    border-right: 1px solid #e0e0e0;
    align-items: center;
}
.ribbon-group:last-child {
    border-right: none;
}

.ribbon-group button {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: none;
    border: none;
    padding: 8px;
    cursor: pointer;
    border-radius: 4px;
    width: 60px;
}
.ribbon-group button:hover {
    background-color: #e6f2fa;
}
.ribbon-group button i {
    font-size: 20px;
    color: var(--primary-color);
    margin-bottom: 5px;
}
.ribbon-group button span {
    font-size: 12px;
}
.ribbon-group button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: none;
}

/* Canvas */
#canvas-container {
    flex-grow: 1;
    overflow: hidden;
    background: var(--canvas-bg);
    position: relative;
    cursor: grab;
}
#canvas-container:active {
    cursor: grabbing;
}

#canvas {
    width: 100%;
    height: 100%;
    transform-origin: 0 0;
}

/* Nodes */
.node {
    position: absolute;
    background-color: var(--node-bg);
    border: 2px solid var(--node-border);
    border-radius: 8px;
    padding: 15px;
    box-shadow: var(--node-shadow);
    min-width: 180px;
    max-width: 250px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    transition: border-color 0.2s, background-color 0.2s;
}
.node.edit-mode {
    cursor: default;
}
.node.view-mode {
    cursor: default;
}
.node.linking-from {
    animation: pulse-blue 1.5s infinite;
}
.node.linking-to:hover {
    border-color: var(--primary-hover);
    background-color: #e6f2fa;
}


.node.selected {
    border-color: var(--selected-node-border);
    border-width: 3px;
}
.node.start-node {
    background-color: var(--start-node-bg);
    border-color: var(--start-node-border);
}
.node.start-node.selected {
    border-color: var(--selected-node-border);
}
.node.current-view-node {
     box-shadow: 0 0 15px 5px var(--primary-color);
}


.node-text {
    font-size: 14px;
    min-height: 40px;
}

.node-choices {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.node-choice {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px;
    background-color: #f0f0f0;
    border-radius: 4px;
    font-size: 13px;
}
.node-choice button {
    background: none;
    border: 1px solid #ccc;
    color: var(--primary-color);
    cursor: pointer;
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 12px;
}
.node-choice button:hover {
    background-color: #e6f2fa;
}
.node-choice.view-mode-choice {
    cursor: pointer;
    background-color: var(--primary-color);
    color: white;
    justify-content: center;
}
.node-choice.view-mode-choice:hover {
    background-color: var(--primary-hover);
}

/* Lines */
.leader-line {
    transition: opacity 0.3s;
}

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background-color: var(--modal-overlay-bg);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}
.modal-content {
    background-color: white;
    padding: 25px;
    border-radius: 8px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 15px;
}
.modal-close-btn {
    position: absolute;
    top: 10px; right: 10px;
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #888;
}
.modal-content h3 {
    margin-bottom: 10px;
}
.modal-content textarea {
    width: 100%;
    min-height: 100px;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 14px;
    resize: vertical;
}
.modal-content button.primary {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 4px;
    cursor: pointer;
    align-self: flex-end;
}
.modal-content button.primary:hover {
    background-color: var(--primary-hover);
}
#node-editor-choices {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 200px;
    overflow-y: auto;
    padding: 5px;
    background: #f9f9f9;
    border-radius: 4px;
}
.choice-editor {
    display: flex;
    gap: 10px;
    align-items: center;
}
.choice-editor input {
    flex-grow: 1;
    padding: 8px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
}
.choice-editor button {
    padding: 8px;
    border: 1px solid #ccc;
    background: none;
    cursor: pointer;
    border-radius: 4px;
}
.choice-editor button.link-btn { color: var(--primary-color); }
.choice-editor button.delete-choice-btn { color: #E53935; }

#ai-spinner {
    text-align: center;
    font-size: 1.2em;
    color: var(--primary-color);
}
#ai-spinner i {
    margin-right: 10px;
}

/* Toast Notification */
.toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background-color: #333;
    color: white;
    padding: 12px 20px;
    border-radius: 25px;
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s, bottom 0.3s;
}
.toast.show {
    opacity: 1;
    visibility: visible;
    bottom: 30px;
}

@keyframes pulse-blue {
    0% { box-shadow: 0 0 0 0 rgba(0, 120, 212, 0.7); }
    70% { box-shadow: 0 0 0 10px rgba(0, 120, 212, 0); }
    100% { box-shadow: 0 0 0 0 rgba(0, 120, 212, 0); }
}

@media (max-width: 600px) {
    .ribbon-group button span {
        display: none;
    }
    .ribbon-group button {
        width: 48px;
    }
    .ribbon-group {
        padding: 0 5px;
    }
}

