/* static/style.css */

/* Global Box Sizing */
*, *::before, *::after {
    box-sizing: border-box;
}

/* Basic Reset & Body */
html {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: sans-serif;
    display: flex;
    flex-direction: column;
    color: #333;
    background-color: #fff;
    margin: 0;
    padding: 5px;
    height: 100vh; /* Make body exactly viewport height */
    overflow: hidden;   /* Prevent body from scrolling */
}

/* Header */
header {
    background-color: #f0f0f0;
    padding: 10px 20px;
    border-bottom: 1px solid #ccc;
    flex-shrink: 0;
    justify-content: space-between;
    display: flex; 
    align-items: center;
}
header h1 {
    margin: 0;
    font-size: 1.5em;
}

header h2 {
    margin: 0; /* Remove default margins */
    font-size: 1.2rem; /* Make font smaller (adjust value as needed) */
    /* You can add other styles like color, font-weight etc. */
    color: #569bdb;
    font-weight: normal;
}


/* Main Layout Container - Flex */
.main-container {
    display: flex;
    flex-grow: 1;
    min-height: 0;
    overflow: hidden;
}

/* Sidebar Styling */
.sidebar {
    flex: 0 0 205px;
    border-right: 1px solid #ccc;
    background-color: #f8f8f8;
    font-size: 0.85rem;
    display: flex;
    flex-direction: column;
    min-height: 0;
    position: relative;
    overflow: hidden;
}

#paramsForm {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    min-height: 0;
    padding: 10px;
    padding-bottom: 0;
    overflow: hidden;
}

/* Scrollable part of the form */
.form-scroll-content {
    overflow-y: scroll;
    flex-grow: 1;
    min-height: 0;
    padding-bottom: 10px; /* Space above footer */
}

#param-grid {
    display: grid;
    /* Adjusted columns for better auto-sizing potential */
    grid-template-columns: 90px 1fr;
    gap: 6px 10px;
    align-items: center;
    margin-bottom: 15px;
}
#param-grid label {
    text-align: right; font-weight: bold; font-size: 0.9em; color: #555; padding-right: 5px;
}
#param-grid input[type="number"],
#param-grid input[type="text"],
#param-grid select { width: 100%; padding: 5px 8px; font-size: 0.9em; border: 1px solid #ccc; border-radius: 4px; }
#param-grid .section-header { grid-column: 1 / -1; margin-top: 20px; margin-bottom: 10px; padding-bottom: 5px; border-bottom: 1px solid #ddd; }
#param-grid .section-header:first-of-type { margin-top: 0; }
#param-grid .section-header h3 { margin: 0; font-size: 1.1em; color: #333; }
#param-grid hr.section-separator {
    grid-column: 1 / -1; width: 80%; margin: 25px auto 15px auto; border: none; height: 2px; background-color: transparent; border-top: 2px dashed #ccc;
}

/* Sticky form footer */
.form-footer {
    position: sticky; bottom: 0; left: 0; right: 0; background-color: #f8f8f8; padding: 15px 20px; border-top: 1px solid #ccc; flex-shrink: 0; z-index: 10;
}

#paramsForm button[type="submit"] {
    padding: 10px 20px; font-size: 1em; background-color: #007bff; color: white; border: none; border-radius: 5px; cursor: pointer; transition: background-color 0.2s; display: block; width: 100%;
}
#paramsForm button[type="submit"]:hover:not(:disabled) { background-color: #0056b3; }

.error-message {
    /* Core Appearance Styles (Keep or adjust) */
    color: #dc3545;
    font-weight: bold;
    font-family: monospace;
    padding: 15px 25px;       /* Adjust padding as needed */
    background-color: #f8d7da;
    border: 1px solid #f5c6cb;
    border-radius: 5px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    min-height: 1.2em;
    text-align: center;
    white-space: pre-wrap;
    display: none;            /* Hidden by default */

    /* Sizing */
    width: auto;              /* Let content and padding define width */
    max-width: 90%;           /* Limit width within the container */
    box-sizing: border-box;

    /* REMOVE Absolute Positioning Styles */
    /* position: absolute; */
    /* top: 15px; */
    /* left: 50%; */
    /* transform: translateX(-50%); */
    /* z-index: 50; */
    /* width: 90%; */         /* Replaced by auto/max-width */
}
.error-message.visible { display: block; }

.error-message.visible + #simulation-svg {
    display: none;
}


/* Content Area Wrapper */
.content-area-wrapper {
    flex: 1;
    display: flex;
    align-items: stretch; /* Ensures children take full height */
    padding: 5px;
    gap: 0; /* Remove existing gap, resizers will create visual separation */
    min-width: 0;
    min-height: 0;
    overflow: hidden;
}

/* Individual Legend Area Styling */
.legend-area {
    flex-basis: 200px;
    flex-shrink: 0;
    flex-grow: 0;
    min-width: 100px;
    max-width: 500px;
    background-color: #fdfdfd;
    border: 1px solid #ddd;
    padding: 0; /* Padding on h2 and pre */
    overflow-y: scroll; /* Prevent legend area itself from scrolling; pre will scroll */
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.legend-area h2 {
    margin-top: 0;
    font-size: 1.15rem; /* Restore font size for h2 */
    margin-bottom: 0px;
    padding-bottom: 0px;
    border-bottom: 1px solid #eee;
    font-family: sans-serif;
    color: #444;
    position: sticky;
    top: 0;
    background-color: #fdfdfd;
    z-index: 1;
    flex-shrink: 0;
    text-align: center;
    white-space: normal;
    padding-top: 5px;
    padding-bottom: 5px;
}
.legend-area pre {
    margin: 0;
    padding-top: 15px;
    padding-bottom: 10px;
    padding-left: 10px; 
    font-family: monospace; /* Set font-family here */
    font-size: 0.75rem; /* Restore specific font size for pre (was inherited) */
    color: #555;
    flex-grow: 1;
    white-space: pre;
    overflow-x: visible;
}

/* Simulation Area Styling */
.simulation-area {
    flex: 1 1 0; /* Grow and shrink as needed, taking remaining space */
    /* ... (your existing simulation area styles) ... */
    min-width: 300px; /* Example: Set a minimum width for the central area */
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

.vertical-resizer {
    flex: 0 0 6px; /* Width of the resizer bar, don't grow or shrink */
    background-color: #ccc;
    cursor: col-resize; /* Cursor indicating horizontal resize */
    /* To center the bar visually if it's inside a gap, or use margins */
    /* margin: 0 5px; */ /* If you want space around it, adjust .content-area-wrapper gap instead */
    border-left: 1px solid #bbb;
    border-right: 1px solid #bbb;
    min-height: 100%; /* Make it full height of the wrapper */
    box-sizing: border-box;
    z-index: 20; /* Ensure it's above other content if overlapping occurs */
    margin-left: 8px;  /* Adjust this value as needed */
    margin-right: 8px; /* Adjust this value as needed */
}

.vertical-resizer:hover {
    background-color: #b7b4b4;
}

/* Controls and Status Area */
.controls, #status-area {
    flex-shrink: 0;
}
.controls {
    margin-bottom: 2px; display: flex; flex-wrap: wrap; gap: 8px 12px; justify-content: center; align-items: center; border-bottom: 1px solid #eee; padding: 8px; padding-bottom: 8px; background-color: #f8f8f8; border-radius: 5px; white-space: pre;
}
/* ... (rest of controls styles remain the same) ... */
.controls button, .controls input[type="range"], .controls input[type="number"], .controls label, .controls span { padding: 8px 12px; font-size: 0.9em; vertical-align: middle; }
.controls label { padding-right: 2px; }
.controls span { padding-left: 0; min-width: 25px; text-align: right; }
.controls input[type="range"] { cursor: pointer; padding: 0; }
.controls input[type="number"] { width: 70px; padding: 6px 8px; border: 1px solid #ccc; border-radius: 4px; }
.controls button { background-color: #6c757d; color: white; border: none; border-radius: 4px; cursor: pointer; transition: background-color 0.2s; }
.controls button:hover:not(:disabled) { background-color: #5a6268; }
#playBtn { background-color: #28a745; }
#playBtn:hover:not(:disabled) { background-color: #218838; }
#pauseBtn { background-color: #ffc107; color: #333; }
#pauseBtn:hover:not(:disabled) { background-color: #e0a800; }
#runToBtn { background-color: #17a2b8; }
#runToBtn:hover:not(:disabled) { background-color: #138496; }

.control-group {
    display: flex;         /* Make the group itself a flex container */
    align-items: center;   /* Vertically align the label, input, and button within the group */
    gap: 5px;              /* Optional: adds a small space between items in the group */
    flex-shrink: 0;        /* Prevents this group from shrinking if .controls is tight for space.
                               This helps keep it on one line. */
}

/* Optional: if you want to ensure these specific items don't shrink individually within their group */
.control-group label,
.control-group input[type="number"],
.control-group button {
    flex-shrink: 0;
}


#status-area {
    margin-bottom: 10px; padding: 8px 15px; font-weight: bold; text-align: center; font-size: 1.1em; background-color: #e9ecef; border-radius: 4px; color: #495057;
}

#simulation-svg-container {
    /* height will be set by JS; remove flex-grow/shrink if JS solely controls height */
    /* flex-grow: 1; REMOVED */
    /* flex-shrink: 1; REMOVED */
    min-height: 50px; /* Keep min-height */
    width: 100%; 
    border: 1px solid #ccc; 
    background-color: #fdfdfd;
    position: relative; 
    overflow: hidden; 
    border-radius: 2px;
    display: grid; 
    place-items: center; 
    padding: 0px; 
    box-sizing: border-box;
}

.animation-header-text {
    position: absolute;
    top: 10px;          /* Position from the top of the container's padding edge */
    left: 10px;         /* Position from the left of the container's padding edge */
    font-size: 1.2em;   /* Larger font size for a header */
    font-weight: bold;  /* Bold text */
    color: #333;        /* Header text color */
    padding-bottom: 5px; /* Optional: space below the text if you add a border */
    /* border-bottom: 2px solid #ddd; /* Optional: an underline for the header */
    z-index: 10;        /* Ensure it's above the SVG content */
    display: none;      /* Hidden by default, JS will make it visible */
    background-color: rgba(253, 253, 253, 0.8); /* Optional: slight background for readability over SVG */
    padding: 4px 8px; /* Optional: padding around the text */
    border-radius: 3px; /* Optional: slightly rounded corners for the background */
}

.animation-header-text.visible {
    display: block; /* Or 'inline-block' or 'flex' depending on needs */
}

/* SVG Styling */
#simulation-svg {
    display: block; /* Remove extra space below SVG */
    max-width: 100%;
    max-height: 100%;
    object-fit: contain; /* Ensure SVG scales within bounds */
}

#horizontal-resizer {
    width: 100%;
    height: 6px; /* Height of the draggable bar */
    background-color: #ccc; /* Color of the bar */
    cursor: row-resize;  /* Cursor indicating vertical resize */
    flex-shrink: 0; /* Prevent the resizer from shrinking */
    display: none; /* Initially hidden, shown by JS */
    border-top: 1px solid #bbb;
    border-bottom: 1px solid #bbb;
    box-sizing: border-box;
    margin-top: 5px;  /* Adjust this value as needed */
    margin-bottom: 5px; /* Adjust this value as needed */
}
/* Style on hover for better feedback */
#horizontal-resizer:hover {
    background-color: #bbb;
}

#torus-plot-container {
    /* height will be set by JS; remove flex-grow/shrink if JS solely controls height */
    /* flex-grow: 1; REMOVED */
    /* flex-shrink: 1; REMOVED */
    min-height: 50px; /* Keep min-height */
    width: 100%; 
    margin-top: 0; 
    border: 1px solid #ccc;
    background-color: #ffffff; 
    border-radius: 4px; 
    display: none; /* JS will show it */
    box-sizing: border-box; 
    padding: 10px; 
    overflow: hidden; /* Clip Plotly */
}

/* Completion Popup Styles - No changes */
#completion-popup {
    position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); max-width:90%; max-height: 90vh; background-color: rgba(248, 248, 248, 0.98); border: 1px solid #aaa; border-radius: 8px; box-shadow: 0 5px 20px rgba(0, 0, 0, 0.25); z-index: 1000; display: none; overflow: hidden;
}
.popup-content { padding: 20px 25px 25px 25px; position: relative; max-height: calc(80vh - 40px); overflow-y: scroll; }
.popup-content h2 { margin-top: 0; margin-bottom: 15px; color: #333; text-align: center; font-size: 1.4em; }
#completion-area { font-size: 1.1em; line-height: 1.1; font-family: monospace; text-align: center; font-weight: bold; padding: 15px; border: 1px solid #b0c4de; background-color: rgba(150,250,150,0.3); color: #333; white-space: pre; border-radius: 4px; }
#closeCompletionPopupBtn { position: absolute; top: 10px; right: 15px; background: none; border: none; font-size: 1.8em; line-height: 1; color: #888; cursor: pointer; padding: 0; }
#closeCompletionPopupBtn:hover { color: #333; }

/* General Styles - No changes */
button:disabled { background-color: #ccc !important; color: #666 !important; cursor: not-allowed !important; opacity: 0.7; }
input:disabled, select:disabled { background-color: #e9ecef; cursor: not-allowed; opacity: 0.7; }
h1, h2, h3 { margin-bottom: 0.75em; }
input:disabled { background-color: #e9ecef; opacity: 0.65; cursor: not-allowed; color: #6c757d; border-color: #ced4da; }
