body {
    font-family: Arial, sans-serif;
    margin: 0;
    background-color: #f4f4f4;
    color: #333;
    /* Prevent body scrolling */
    overflow: hidden;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

.header {
    background-color: #4CAF50;
    color: white;
    padding: 10px 20px;
    /* Reduced padding */
    text-align: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    flex-shrink: 0;
    /* Don't shrink */
}

h1,
h2 {
    color: #333;
    margin-top: 0;
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
    margin-bottom: 15px;
}

h1 {
    font-size: 1.8em;
    margin: 0;
    padding: 0;
    border: 0;
}

h2 {
    font-size: 1.2em;
}

/* === NEW: Main Layout === */
.container-row {
    display: flex;
    flex-direction: row;
    flex-grow: 1;
    /* Take remaining height */
    overflow: hidden;
    /* Prevent scrolling */
}

.container-column {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    overflow: auto;
    padding: 20px 30px 20px 20px;
    gap: 20px;
}

.palette {
    flex: 0 0 250px;
    padding: 15px;
    background-color: white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    overflow-y: auto;
    height: 100%;
}

/* === Canvas === */
/* This is the main container for the H2 and the window */
.canvas-area {
    flex: 1 1 60%;
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - 190px);
}

.canvas-area h2 {
    flex-shrink: 0;
    /* Don't shrink H2 */
    /* All other H2 styles are fine */
}

/* NEW: This is the visible "window" */
.canvas-window {
    flex-grow: 1;
    /* Fill available space */
    border: 2px dashed #ccc;
    position: relative;
    background-color: white;
    border-radius: 8px;
    overflow: hidden;
    /* This is the "window" */
}

/* NEW: This is the "world" that pans/zooms */
.canvas-viewport {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    transform-origin: 0 0;
    /* Makes zoom math easier */
    cursor: grab;
}

.canvas-viewport.panning {
    cursor: grabbing;
}

/* The placeholder is now inside the viewport */
.placeholder {
    position: absolute;
    top: 150px;
    left: 50%;
    transform: translateX(-50%);
    color: #888;
    font-style: italic;
    z-index: 0;
    pointer-events: none;
    /* Don't intercept clicks */
}

.canvas-area .placeholder {
    color: #888;
    text-align: center;
    padding-top: 150px;
    font-style: italic;
}

/* === NEW: Output Areas === */
.output-area {
    flex: 1 1 40%;
    /* Take 40% of vertical space */
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    padding: 15px;
    display: flex;
    flex-direction: column;
    overflow: auto;
    /* Contained scrolling */
    min-height: calc(100vh - 190px);
}

.output-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.output-header h2 {
    margin: 0;
    padding-bottom: 0;
    border: 0;
}

pre {
    background-color: #f0f0f0;
    border: 1px solid #ddd;
    padding: 10px;
    min-height: 100px;
    overflow: auto;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.9em;
    white-space: pre-wrap;
}

#turtleOutput {
    flex-grow: 1;
    overflow: auto;
    margin-top: 15px;
    border: 1px solid #ddd;
    padding: 10px;
    background-color: #f9f9f9;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.9em;
    white-space: pre;
    resize: none;
}


/* === Sidebar Styles === */
.draggable-item {
    background-color: #e0e0e0;
    border: 1px solid #ccc;
    padding: 8px 12px;
    margin-bottom: 10px;
    cursor: grab;
    border-radius: 4px;
    text-align: center;
}

.draggable-item:hover {
    background-color: #d0d0d0;
}

.file-upload-label {
    display: block;
    background-color: #007bff;
    color: white;
    padding: 10px 15px;
    border-radius: 5px;
    cursor: pointer;
    text-align: center;
    margin-bottom: 10px;
    font-size: 0.9em;
}

.file-upload-label:hover {
    background-color: #0056b3;
}

#fileUploader {
    display: none;
}

.ontology-section {
    margin-bottom: 15px;
}

.ontology-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 5px;
}

.ontology-header h3 {
    margin: 0;
    font-size: 1.1em;
}

.add-btn {
    background-color: #28a745;
    color: white;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    line-height: 24px;
}

.add-btn:hover {
    background-color: #218838;
}

.ontology-list {
    list-style-type: none;
    padding-left: 0;
    margin: 0;
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid #eee;
    border-radius: 4px;
}

.ontology-list li {
    padding: 6px 10px;
    font-size: 0.9em;
    border-bottom: 1px solid #eee;
}

.ontology-list li:last-child {
    border-bottom: none;
}

.ontology-list li .iri {
    display: block;
    font-size: 0.85em;
    color: #555;
    word-break: break-all;
}

/* === Canvas Element Styles === */
.canvas-element {
    position: absolute;
    background-color: #b3e0ff;
    border: 1px solid #66b3ff;
    padding: 10px 15px;
    border-radius: 8px;
    cursor: move;
    min-width: 150px;
    text-align: left;
    z-index: 10;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.canvas-element.selected {
    border: 2px solid #ff4500;
}

.canvas-element .label {
    font-weight: bold;
    display: block;
    margin-bottom: 5px;
    border-bottom: 1px solid #99cfff;
    padding-bottom: 5px;
}

.canvas-element .info {
    font-size: 0.9em;
    color: #333;
    line-height: 1.4;
}

.canvas-element .info .key {
    font-weight: 600;
}

.canvas-element .iri {
    font-size: 0.8em;
    color: #555;
    word-break: break-all;
    margin-top: 5px;
}

.canvas-element .element-actions {
    margin-top: 8px;
    border-top: 1px solid #99cfff;
    padding-top: 8px;
    text-align: right;
}

.canvas-element .element-actions button {
    background: none;
    border: none;
    color: #007bff;
    cursor: pointer;
    font-size: 0.9em;
    margin: 0 3px;
    padding: 0;
}

.canvas-element .element-actions button:hover {
    text-decoration: underline;
}

.connector {
    position: absolute;
    top: 50%;
    right: -8px;
    width: 16px;
    height: 16px;
    background-color: #007bff;
    border: 2px solid white;
    border-radius: 50%;
    cursor: crosshair;
    transform: translateY(-50%);
    z-index: 11;
}

.connector:hover {
    background-color: #0056b3;
}

/* === SVG Styles === */
.svg-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    /* NEW: Stop SVG from intercepting pan clicks */
    pointer-events: none;
}

.svg-canvas .connection-line {
    stroke: #555;
    stroke-width: 3px;
    fill: none;
}

/* Make hitboxes clickable again */
.svg-canvas .connection-hitbox {
    pointer-events: all;
    /* Re-enable pointer for hitboxes */
    stroke: transparent;
    stroke-width: 12px;
    fill: none;
    cursor: pointer;
}

.svg-canvas .connection-line.hovered {
    stroke: #007bff;
    stroke-width: 5px;
}

.temp-connection-line {
    stroke: #007bff;
    stroke-width: 3px;
    stroke-dasharray: 5, 5;
    fill: none;
}

/* === Modal Styling === */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.4);
}

.modal-content {
    background-color: #fefefe;
    margin: 10% auto;
    padding: 20px;
    border: 1px solid #888;
    width: 80%;
    max-width: 500px;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    position: relative;
}

.close-button {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    position: absolute;
    top: 10px;
    right: 20px;
    cursor: pointer;
}

.close-button:hover,
.close-button:focus {
    color: black;
    text-decoration: none;
}

.modal-content label {
    display: block;
    margin-top: 10px;
    margin-bottom: 5px;
    font-weight: bold;
}

.modal-content input[type="text"],
.modal-content select {
    width: calc(100% - 22px);
    padding: 10px;
    margin-bottom: 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
}

#tboxFullIRI {
    background-color: #eee;
}

.modal-hr {
    margin: 20px 0;
    border: none;
    border-top: 1px solid #eee;
}

.modal-actions {
    display: flex;
    justify-content: space-between;
}

.modal-actions button {
    padding: 8px 12px;
    font-size: 0.9em;
    margin-top: 0;
}

/* === Button Styles === */
button,
#saveProperties,
#saveConnection,
#saveTboxItem {
    background-color: #007bff;
    color: white;
    border: none;
    padding: 10px 15px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1em;
}

button:hover,
#saveProperties:hover,
#saveConnection:hover,
#saveTboxItem:hover {
    background-color: #0056b3;
}

.btn-secondary {
    background-color: #6c757d;
}

.btn-secondary:hover {
    background-color: #5a6268;
}

.btn-danger {
    background-color: #dc3545;
}

.btn-danger:hover {
    background-color: #c82333;
}

.hidden {
    display: none;
}

.visible {
    display: inline-block;
}
