/* Dialogue Designer - Complete Styles */

:root {
    --bg-primary: #1a1a2e;
    --bg-secondary: #16213e;
    --bg-tertiary: #0f3460;
    --bg-node: #1f2940;
    --text-primary: #eaeaea;
    --text-secondary: #a0a0a0;
    --accent-blue: #4a9eff;
    --accent-green: #00d26a;
    --accent-red: #ff6b6b;
    --accent-purple: #9c27b0;
    --accent-orange: #ff9800;
    --accent-yellow: #ffd93d;
    --border-color: #2a3f5f;
    --node-dialogue: #e74c3c;
    --node-logic: #2ecc71;
    --node-variable: #3498db;
    --node-comment: #9b59b6;
    --node-start: #f39c12;
    --node-end: #95a5a6;
    --shadow: 0 4px 20px rgba(0,0,0,0.4);
}

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    overflow: hidden;
    height: 100vh;
}

/* Header */
.header {
    background: linear-gradient(135deg, var(--bg-secondary) 0%, var(--bg-tertiary) 100%);
    border-bottom: 2px solid var(--border-color);
    padding: 12px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 65px;
    z-index: 1000;
}

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

.logo {
    font-size: 22px;
    font-weight: bold;
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.btn {
    padding: 8px 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
}

.btn:hover {
    background: var(--accent-blue);
    border-color: var(--accent-blue);
    transform: translateY(-1px);
}

.btn-primary {
    background: var(--accent-blue);
    border-color: var(--accent-blue);
}

.btn-success {
    background: var(--accent-green);
    border-color: var(--accent-green);
}

.btn-danger {
    background: var(--accent-red);
    border-color: var(--accent-red);
}

input[type="text"], select, textarea {
    padding: 8px 12px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
}

input[type="text"]:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(74, 158, 255, 0.2);
}

/* Main Container */
.main-container {
    display: flex;
    height: calc(100vh - 65px);
}

/* Sidebar */
.sidebar {
    width: 280px;
    background: var(--bg-secondary);
    border-right: 2px solid var(--border-color);
    overflow-y: auto;
    padding: 15px;
}

.sidebar-section {
    margin-bottom: 20px;
    background: var(--bg-primary);
    border-radius: 10px;
    padding: 15px;
    border: 1px solid var(--border-color);
}

.sidebar-section h3 {
    font-size: 13px;
    text-transform: uppercase;
    color: var(--accent-blue);
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
    letter-spacing: 0.5px;
}

.node-palette {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.node-button {
    padding: 12px 8px;
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    cursor: grab;
    text-align: center;
    font-size: 12px;
    font-weight: 500;
    transition: all 0.2s;
    color: var(--text-primary);
    user-select: none;
}

.node-button:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.node-button:active {
    cursor: grabbing;
    transform: scale(0.95);
}

.node-button.dialogue { border-color: var(--node-dialogue); background: rgba(231, 76, 60, 0.1); }
.node-button.logic { border-color: var(--node-logic); background: rgba(46, 204, 113, 0.1); }
.node-button.variable { border-color: var(--node-variable); background: rgba(52, 152, 219, 0.1); }
.node-button.comment { border-color: var(--node-comment); background: rgba(155, 89, 182, 0.1); }
.node-button.end { border-color: var(--node-end); background: rgba(149, 165, 166, 0.1); }

.hint {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 10px;
    text-align: center;
    font-style: italic;
}

.database-list {
    max-height: 150px;
    overflow-y: auto;
    margin-bottom: 10px;
}

.database-item {
    padding: 8px 10px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    margin-bottom: 6px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
}

.database-item-name {
    font-weight: 500;
}

.database-item-type {
    font-size: 10px;
    color: var(--text-secondary);
    background: var(--bg-primary);
    padding: 2px 8px;
    border-radius: 4px;
}

.database-item-delete {
    background: none;
    border: none;
    color: var(--accent-red);
    cursor: pointer;
    font-size: 14px;
    padding: 2px 6px;
    border-radius: 4px;
    opacity: 0.6;
}

.database-item-delete:hover {
    opacity: 1;
    background: rgba(255, 107, 107, 0.2);
}

.add-item-form {
    display: flex;
    gap: 6px;
}

.add-item-form input {
    flex: 1;
    min-width: 0;
}

.add-item-form select {
    width: 80px;
}

.help-text {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.8;
}

.help-text p {
    margin-bottom: 4px;
}

/* Canvas Area */
.canvas-container {
    flex: 1;
    position: relative;
    overflow: hidden;
    background: var(--bg-primary);
    background-image: 
        radial-gradient(circle, var(--border-color) 1px, transparent 1px);
    background-size: 25px 25px;
}

#connectionsSvg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

#nodesContainer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
}

/* Nodes */
.node {
    position: absolute;
    background: var(--bg-node);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    min-width: 220px;
    cursor: move;
    box-shadow: var(--shadow);
    user-select: none;
    transition: box-shadow 0.2s, border-color 0.2s;
}

.node:hover {
    box-shadow: 0 6px 30px rgba(0,0,0,0.5);
}

.node.selected {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(74, 158, 255, 0.3), var(--shadow);
}

.node.dragging {
    opacity: 0.8;
    z-index: 1000;
}

.node-header {
    padding: 12px 15px;
    border-radius: 10px 10px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
    font-size: 13px;
}

.node.start .node-header { background: linear-gradient(135deg, var(--node-start), #e67e22); }
.node.dialogue .node-header { background: linear-gradient(135deg, var(--node-dialogue), #c0392b); }
.node.choice .node-header { background: linear-gradient(135deg, #e74c3c, #9b59b6); }
.node.condition .node-header { background: linear-gradient(135deg, var(--node-logic), #27ae60); }
.node.set-variable .node-header { background: linear-gradient(135deg, var(--node-variable), #2980b9); }
.node.execute .node-header { background: linear-gradient(135deg, var(--node-logic), #1abc9c); }
.node.random .node-header { background: linear-gradient(135deg, var(--accent-orange), var(--accent-yellow)); color: #333; }
.node.comment .node-header { background: linear-gradient(135deg, var(--node-comment), #8e44ad); }
.node.end .node-header { background: linear-gradient(135deg, var(--node-end), #7f8c8d); }

.node-type-icon {
    font-size: 16px;
}

.node-content {
    padding: 12px 15px;
    font-size: 12px;
    color: var(--text-secondary);
    min-height: 40px;
}

.node-content-text {
    margin-bottom: 8px;
    color: var(--text-primary);
    font-size: 13px;
    line-height: 1.4;
    max-height: 60px;
    overflow: hidden;
}

.node-content-meta {
    font-size: 11px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Choice options display */
.choice-options-preview {
    margin-top: 8px;
    border-top: 1px solid var(--border-color);
    padding-top: 8px;
}

.choice-option-preview {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 0;
    font-size: 12px;
}

.choice-option-number {
    background: var(--accent-blue);
    color: white;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: bold;
}

.choice-option-text {
    flex: 1;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Ports */
.node-ports {
    position: relative;
    height: 20px;
}

.port {
    position: absolute;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    cursor: crosshair;
    transition: all 0.2s;
    border: 2px solid var(--bg-node);
    z-index: 10;
}

.port:hover {
    transform: scale(1.4);
    box-shadow: 0 0 10px currentColor;
}

.port.input {
    background: var(--accent-green);
    top: -7px;
    left: 50%;
    transform: translateX(-50%);
}

.port.input:hover {
    transform: translateX(-50%) scale(1.4);
}

.port.output {
    background: var(--accent-red);
    bottom: -7px;
}

.port.output.single {
    left: 50%;
    transform: translateX(-50%);
}

.port.output.single:hover {
    transform: translateX(-50%) scale(1.4);
}

/* Multiple output ports for choices */
.output-ports {
    position: absolute;
    bottom: -7px;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-around;
    padding: 0 20px;
}

.output-port-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.port-label {
    font-size: 9px;
    color: var(--text-secondary);
    margin-top: 8px;
}

/* Condition ports */
.condition-ports {
    position: absolute;
    bottom: -7px;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-around;
    padding: 0 40px;
}

.port.true-port {
    background: var(--accent-green);
}

.port.false-port {
    background: var(--accent-red);
}

/* Controls */
.canvas-controls {
    position: absolute;
    bottom: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 100;
}

.control-group {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 8px;
    display: flex;
    gap: 8px;
    align-items: center;
}

.zoom-display {
    padding: 6px 12px;
    background: var(--bg-primary);
    border-radius: 4px;
    font-size: 12px;
    min-width: 55px;
    text-align: center;
    font-weight: 500;
}

/* Drop Zone */
.drop-zone-indicator {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    padding: 40px 60px;
    border: 3px dashed var(--accent-blue);
    border-radius: 20px;
    background: rgba(74, 158, 255, 0.1);
    color: var(--accent-blue);
    font-size: 18px;
    font-weight: 500;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s;
    z-index: 50;
}

.drop-zone-indicator.active {
    opacity: 1;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.8);
    z-index: 2000;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(5px);
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: 16px;
    padding: 0;
    max-width: 500px;
    width: 90%;
    max-height: 85vh;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
    animation: modalSlideIn 0.3s ease-out;
}

.modal-large {
    max-width: 700px;
}

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

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 25px;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
    font-size: 18px;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 28px;
    cursor: pointer;
    padding: 0;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: all 0.2s;
}

.modal-close:hover {
    background: var(--accent-red);
}

.modal-body {
    padding: 25px;
    overflow-y: auto;
    max-height: 60vh;
}

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

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: 8px;
    font-size: 14px;
}

.form-group textarea {
    min-height: 80px;
    resize: vertical;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 20px 25px;
    background: var(--bg-tertiary);
    border-top: 1px solid var(--border-color);
}

/* Export Options */
.export-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.export-option {
    padding: 20px;
    background: var(--bg-primary);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    cursor: pointer;
    text-align: center;
    transition: all 0.2s;
}

.export-option:hover {
    border-color: var(--accent-blue);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.export-option h4 {
    margin-bottom: 6px;
    color: var(--accent-blue);
    font-size: 15px;
}

.export-option p {
    font-size: 11px;
    color: var(--text-secondary);
}

/* Choice Editor */
.choice-list {
    margin-top: 15px;
}

.choice-item {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
    align-items: center;
    padding: 10px;
    background: var(--bg-primary);
    border-radius: 8px;
    border: 1px solid var(--border-color);
    animation: slideIn 0.2s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-10px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.choice-number {
    background: var(--accent-blue);
    color: white;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 13px;
    flex-shrink: 0;
}

.choice-item input {
    flex: 1;
}

.choice-item .btn-danger {
    padding: 8px 12px;
    flex-shrink: 0;
}

.add-choice-btn {
    width: 100%;
    padding: 12px;
    margin-top: 10px;
    background: rgba(0, 210, 106, 0.1);
    border: 2px dashed var(--accent-green);
    color: var(--accent-green);
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
}

.add-choice-btn:hover {
    background: rgba(0, 210, 106, 0.2);
}

/* Print Preview */
.print-preview {
    background: white;
    color: #333;
    padding: 30px;
    border-radius: 8px;
    max-height: 500px;
    overflow-y: auto;
    font-family: 'Times New Roman', serif;
}

.print-preview h1 {
    font-size: 24px;
    margin-bottom: 20px;
    border-bottom: 2px solid #333;
    padding-bottom: 10px;
}

.print-preview h2 {
    font-size: 18px;
    margin: 20px 0 10px;
    color: #555;
}

.print-preview .node-print {
    margin: 15px 0;
    padding: 15px;
    border: 1px solid #ddd;
    border-radius: 8px;
    background: #f9f9f9;
}

.print-preview .node-print-header {
    font-weight: bold;
    margin-bottom: 8px;
    color: #333;
}

.print-preview .node-print-content {
    margin-left: 20px;
    color: #555;
}

.print-preview .choice-print {
    margin: 5px 0 5px 20px;
    padding: 5px 10px;
    background: #eee;
    border-radius: 4px;
}

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

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--bg-tertiary);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--border-color);
}

/* Connection line being drawn */
.connection-line-temp {
    stroke: var(--accent-blue);
    stroke-width: 3;
    stroke-dasharray: 8, 4;
    fill: none;
    animation: dashMove 0.5s linear infinite;
}

@keyframes dashMove {
    to {
        stroke-dashoffset: -12;
    }
}

/* Connection lines */
.connection-line {
    stroke: var(--accent-blue);
    stroke-width: 3;
    fill: none;
    transition: stroke 0.2s;
}

.connection-line:hover {
    stroke: var(--accent-yellow);
    stroke-width: 4;
}

.connection-line.condition-true {
    stroke: var(--accent-green);
}

.connection-line.condition-false {
    stroke: var(--accent-red);
}

/* Print styles */
@media print {
    body * {
        visibility: hidden;
    }
    
    .print-preview, .print-preview * {
        visibility: visible;
    }
    
    .print-preview {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        max-height: none;
        overflow: visible;
    }
}

/* Responsive */
@media (max-width: 768px) {
    .header-center {
        display: none;
    }
    
    .sidebar {
        width: 220px;
    }
    
    .export-options {
        grid-template-columns: 1fr;
    }
}