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

html, body {
    font-family: Arial, sans-serif;
    background-color: #f0f0f0;
    overflow: hidden;
    height: 100vh;
    width: 100vw;
    position: fixed;
    top: 0;
    left: 0;
}

#controls {
    position: fixed;
    top: 10px;
    left: 10px;
    z-index: 1000;
    background: rgba(255, 255, 255, 0.9);
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}

button {
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.3s;
}

#addReservoirBtn {
    background-color: #4CAF50;
    color: white;
}

#addReservoirBtn:hover {
    background-color: #45a049;
}

#tutorialBtn {
    background-color: #9C27B0;
    color: white;
    margin-right: 10px;
}

#tutorialBtn:hover {
    background-color: #7B1FA2;
}

#saveBtn {
    background-color: #2196F3;
    color: white;
}

#saveBtn:hover {
    background-color: #1976D2;
}

#loadBtn {
    background-color: #FF9800;
    color: white;
}

#loadBtn:hover {
    background-color: #F57C00;
}

#clearBtn {
    background-color: #f44336;
    color: white;
}

#clearBtn:hover {
    background-color: #d32f2f;
}

#templatesBtn {
    background-color: #009688;
    color: white;
}

#templatesBtn:hover {
    background-color: #00695C;
}

#status {
    color: #666;
    font-size: 12px;
    min-width: 200px;
}

#canvasContainer {
    width: 100vw;
    height: 100vh;
    overflow: hidden;
}

#reservoirCanvas {
    display: block;
    cursor: crosshair;
    background-color: #fff;
}

/* Modal styles */
.modal {
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0);
    transition: background-color 0.3s ease;
    pointer-events: none;
    visibility: hidden;
}

.modal.show {
    background-color: rgba(0, 0, 0, 0.4);
    pointer-events: all;
    visibility: visible;
}

.modal-content {
    background-color: #fefefe;
    position: fixed;
    right: -500px;
    top: 50%;
    transform: translateY(-50%);
    padding: 20px;
    border: none;
    border-radius: 8px 0 0 8px;
    width: 400px;
    max-width: 90%;
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.3);
    transition: right 0.3s ease;
    max-height: 90vh;
    overflow-y: auto;
}

.modal.show .modal-content {
    right: 0;
}

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

.close:hover,
.close:focus {
    color: black;
}

#reservoirForm {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group {
    display: flex;
    align-items: center;
    margin-bottom: 10px;
    gap: 10px;
}

#reservoirForm label {
    font-weight: bold;
    margin-bottom: 0;
    min-width: 80px;
    flex-shrink: 0;
    text-align: right;
}

#reservoirForm input,
#reservoirForm select {
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    flex: 1;
    z-index: 1000;
}

#reservoirForm input[type="text"],
#reservoirForm select {
    padding: 8px;
    min-width: 120px;
}

/* Custom color picker styling */
.color-picker-container {
    position: relative;
    cursor: pointer;
    flex: 1;
    max-width: 80px;
}

.color-display {
    width: 100%;
    aspect-ratio: 1;
    border: 2px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    position: relative;
    transition: border-color 0.3s ease;
}

.color-display:hover {
    border-color: #4CAF50;
}

/* .color-display::after {
    content: 'Click to change color';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: rgba(255, 255, 255, 0.8);
    font-size: 12px;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
    pointer-events: none;
} */

.color-picker-container input[type="color"] {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
    padding: 0;
    border: none;
}
.color-picker-container input[type="range"] {
    width: 100%;
    margin-top: 5px;
}

#drawInstructions {
    background-color: #e3f2fd;
    padding: 10px;
    border-radius: 4px;
    font-size: 12px;
    color: #1976d2;
    text-align: center;
}

#reservoirForm button {
    padding: 10px 10px;
}

#cancelReservoir {
    background-color: #757575;
    color: white;
}

#createReservoir {
    background-color: #4CAF50;
    color: white;
}

/* Tooltip styles */
.input-with-tooltip {
    position: relative;
    display: flex;
    align-items: center;
    flex: 1;
}

.input-with-tooltip input {
    flex: 1;
    margin-right: 8px;
}

.tooltip-icon {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background-color: #2196F3;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    cursor: pointer;
    user-select: none;
    flex-shrink: 0;
}

.tooltip-icon:hover {
    background-color: #1976D2;
}

.tooltip-content {
    position: absolute;
    top: 25px;
    right: 0;
    background-color: #333;
    color: white;
    padding: 10px;
    border-radius: 4px;
    font-size: 12px;
    line-height: 1.4;
    white-space: nowrap;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.tooltip-content::before {
    content: '';
    position: absolute;
    top: -5px;
    right: 10px;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-bottom: 5px solid #333;
}

.tooltip-content.show {
    opacity: 1;
    visibility: visible;
}

/* Input validation styles */
.form-group input.invalid {
    border-color: #f44336;
    box-shadow: 0 0 0 2px rgba(244, 67, 54, 0.2);
}

#createReservoir:disabled {
    background-color: #cccccc;
    cursor: not-allowed;
    opacity: 0.6;
}

/* Collapsible sections */
.collapsible-section {
    border: 1px solid #ddd;
    border-radius: 4px;
    overflow: hidden;
}

.section-header {
    background-color: #f5f5f5;
    padding: 12px 15px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    user-select: none;
    transition: background-color 0.2s ease;
}

.section-header:hover {
    background-color: #e8e8e8;
}

.section-title {
    font-weight: bold;
    color: #333;
}

.section-toggle {
    font-size: 12px;
    transition: transform 0.2s ease;
    color: #666;
}

.section-toggle.collapsed {
    transform: rotate(-90deg);
}

.section-content {
    padding: 15px;
    background-color: white;
    max-height: 500px;
    overflow-y: auto;
    transition: max-height 0.3s ease;
}

.section-content.collapsed {
    max-height: 0;
    padding: 0 15px;
    overflow: hidden;
}

.section-actions {
    margin-top: 15px;
    text-align: center;
}

.section-actions button {
    background-color: #2196F3;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.2s ease;
}

.section-actions button:hover {
    background-color: #1976D2;
}

/* Items list (variables and constants) */
.items-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.item-card {
    background-color: #f9f9f9;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    padding: 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: box-shadow 0.2s ease;
}

.item-card:hover {
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.item-card .item-key {
    flex: 0 0 120px;
}

.item-card .item-key input {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid #ccc;
    border-radius: 3px;
    font-size: 13px;
}

.item-card .item-value {
    flex: 1;
}

.item-card .item-value input {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid #ccc;
    border-radius: 3px;
    font-size: 13px;
}

.item-card .item-value textarea {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid #ccc;
    border-radius: 3px;
    font-size: 13px;
    resize: vertical;
    min-height: 60px;
    font-family: monospace;
}

.item-card .item-actions {
    flex: 0 0 auto;
}

.item-card .remove-btn {
    background-color: #f44336;
    color: white;
    border: none;
    padding: 6px 10px;
    border-radius: 3px;
    cursor: pointer;
    font-size: 12px;
    transition: background-color 0.2s ease;
}

.item-card .remove-btn:hover {
    background-color: #d32f2f;
}

.item-type-label {
    font-size: 11px;
    color: #666;
    font-weight: bold;
    text-transform: uppercase;
    margin-bottom: 2px;
}

/* Flux-specific styles */
#addFluxBtn {
    background-color: #FF9800;
    color: white;
}

#addFluxBtn:hover {
    background-color: #F57C00;
}

.flux-line {
    stroke: #FF5722;
    stroke-width: 3;
    fill: none;
    stroke-dasharray: 5,5;
}

.flux-point {
    fill: #FF5722;
    stroke: #FFFFFF;
    stroke-width: 2;
    cursor: pointer;
}

.flux-point:hover {
    fill: #D32F2F;
}

.flux-point.selected {
    fill: #FF9800;
    stroke: #FF6F00;
    stroke-width: 3;
}

.path-point-card {
    background-color: #fff3e0;
    border: 1px solid #ffcc02;
    border-radius: 6px;
    padding: 8px 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 5px;
}

.path-point-card .point-coords {
    flex: 1;
    font-family: monospace;
    font-size: 13px;
    color: #333;
}

.path-point-card .point-actions {
    display: flex;
    gap: 5px;
}

.path-point-card .point-actions button {
    padding: 4px 8px;
    font-size: 11px;
    border-radius: 3px;
    border: none;
    cursor: pointer;
}

.move-up-btn {
    background-color: #2196F3;
    color: white;
}

.move-down-btn {
    background-color: #2196F3;
    color: white;
}

.delete-point-btn {
    background-color: #f44336;
    color: white;
}

.step-card {
    background-color: #f0f4ff;
    border: 1px solid #c8d4ff;
    border-radius: 6px;
    padding: 12px;
    margin-bottom: 10px;
}

.step-header {
    display: flex;
    justify-content: between;
    align-items: center;
    margin-bottom: 10px;
}

.step-number {
    background-color: #2196F3;
    color: white;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
}

.step-content {
    display: grid;
    gap: 10px;
    margin-bottom: 10px;
}

.step-field {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 10px;
}

.step-field label {
    font-size: 11px;
    color: #666;
    font-weight: bold;
    min-width: 60px;
    flex-shrink: 0;
}

.step-field input, .step-field textarea {
    padding: 6px 8px;
    border: 1px solid #ccc;
    border-radius: 3px;
    font-size: 13px;
    flex: 1;
}

.step-field select {
    padding: 6px 8px;
    border: 1px solid #ccc;
    border-radius: 3px;
    font-size: 13px;
    flex: 1;
}

.function-dropdowns {
    display: flex;
    gap: 8px;
    flex: 1;
}

.function-dropdowns select {
    flex: 1;
}

.step-field textarea {
    min-height: 60px;
    resize: vertical;
    font-family: monospace;
}

/* Tag input system for inputs/outputs */
.tag-input-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
}

.tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    min-height: 32px;
    padding: 8px;
    border: none;
    border-radius: 3px;
    background-color: transparent;
}

.tag-item {
    display: inline-flex;
    align-items: center;
    background-color: #e3f2fd;
    border: 1px solid #2196F3;
    border-radius: 16px;
    padding: 4px 8px 4px 12px;
    font-size: 12px;
    color: #1976D2;
    cursor: grab;
    user-select: none;
    transition: all 0.2s ease;
    max-width: 150px;
}

.tag-item:hover {
    background-color: #bbdefb;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.tag-item.selected {
    background-color: #ffecb3;
    border-color: #ff9800;
    color: #f57c00;
}

.tag-item.dragging {
    opacity: 0.7;
    transform: rotate(2deg);
    cursor: grabbing;
}

.tag-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}

.tag-remove {
    margin-left: 6px;
    background: none;
    border: none;
    color: #666;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    padding: 0;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease;
}

.tag-remove:hover {
    background-color: rgba(244, 67, 54, 0.1);
    color: #f44336;
}

.tag-input-controls {
    display: flex;
    gap: 6px;
    align-items: center;
}

.tag-input {
    flex: 1;
    padding: 6px 8px;
    border: 1px solid #ccc;
    border-radius: 3px;
    font-size: 13px;
}

.add-tag-btn {
    background-color: #4CAF50;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 3px;
    cursor: pointer;
    font-size: 12px;
    transition: background-color 0.2s ease;
    white-space: nowrap;
}

.add-tag-btn:hover {
    background-color: #45a049;
}

.add-tag-btn:disabled {
    background-color: #cccccc;
    cursor: not-allowed;
}

.step-actions {
    display: flex;
    justify-content: flex-end;
    gap: 5px;
}

.step-actions button {
    padding: 6px 12px;
    font-size: 12px;
    border-radius: 3px;
    border: none;
    cursor: pointer;
}

.move-step-up, .move-step-down {
    background-color: #2196F3;
    color: white;
}

.delete-step {
    background-color: #f44336;
    color: white;
}

#pathInstructions, #fluxInstructions {
    background-color: #e8f5e8;
    padding: 10px;
    border-radius: 4px;
    font-size: 12px;
    color: #2e7d32;
    text-align: center;
    margin-top: 10px;
}

/* Canvas drawing states */
.drawing-mode {
    cursor: crosshair !important;
}

.drawing-active {
    cursor: crosshair !important;
}

/* Reservoir selection highlight */
.reservoir-selected {
    filter: brightness(1.2);
}

/* Templates Modal styles */
#templatesModal .modal-content {
    right: auto;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 600px;
    max-width: 90vw;
    max-height: 80vh;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    transition: opacity 0.3s ease, transform 0.3s ease;
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.9);
}

#templatesModal.show .modal-content {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}
