html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden; /* Prevent main page scrollbars */
}

body {
    font-family: sans-serif;
    background-color: #f4f4f4;
    color: #333;
    display: flex; /* Use flex to manage header + main-container */
    flex-direction: column;
    padding: 10px; /* Padding for content within body */
    box-sizing: border-box;
}

h1 {
    text-align: center;
    color: #2c3e50;
    margin-bottom: 20px;
}

.main-container {
    display: flex;
    gap: 15px;
    flex-grow: 1; /* Takes up all space below h1 (if any) or directly in body */
    overflow: hidden; /* Prevent .main-container itself from scrolling */
    height: calc(100% - 20px); /* Adjust if h1 is present: calc(100% - H1_HEIGHT - 20px) */
                               /* Or simply height: 100% if body padding handles spacing */
    height: 100%; /* Simpler: let body padding handle outer spacing */
}

.box-input-instructions {
    font-size: 0.65em;
    color: #555;
    margin-top: 5px;
}

.column-left {
    flex: 0 0 400px; 
    display: flex;
    flex-direction: column;
    gap: 15px;
    height: 100%; /* Fill height of main-container */
    overflow: hidden; /* Children must manage their own scroll */
}

.column-left > .controls {
    flex-shrink: 0; 
    /* Add overflow-y: auto; if controls content could ever be too tall */
}

.column-left > .results {
    flex-grow: 1; 
    min-height: 0; 
    display: flex; 
    flex-direction: column; 
    overflow-y: auto; /* This is the main scrollbar for the results section */
    /* background-color: lightgoldenrodyellow; */ /* Debug */
}

.column-right {
    flex: 1 1 auto; 
    display: flex;
    flex-direction: column;
    height: 100%; /* Fill height of main-container */
    overflow: hidden; /* Children must manage their own scroll */
}

.controls {
    background-color: #fff;
    padding: 15px;
    border-radius: 6px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.visualization {
    flex-grow: 1; 
    display: flex; 
    flex-direction: column; 
    min-height: 0; 
    width: 100%; 
    height: 100%; 
    /* Add card styles */
    background-color: #fff;
    padding: 15px;
    border-radius: 6px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    box-sizing: border-box; /* Include padding in width/height calculation */
}

.visualization h2 {
    flex-shrink: 0; 
    margin-top: 0; 
    margin-bottom: 10px;
}

#pallet-canvas {
    flex-grow: 1; 
    width: 100%;
    display: block; 
    border: 1px solid #ddd;
    background-color: #e9e9e9;
    min-height: 200px; /* Reduced min-height slightly */
}

#controls-instructions {
    padding: 8px 0;
    text-align: center;
    font-size: 0.85em;
    color: #555;
    background-color: #f9f9f9; /* Slightly different background */
    border-top: 1px solid #eee;
    flex-shrink: 0; /* Prevent it from shrinking */
}

#controls-instructions p {
    margin: 0;
    padding: 5px;
}

.results {
    background-color: #fff;
    padding: 15px;
    border-radius: 6px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    /* display:flex, flex-direction:column, overflow-y:auto already set under .column-left > .results */
}

#results-summary {
    flex-shrink: 0; /* Prevent summary from shrinking */
    padding-bottom: 10px; /* Add some space below summary */
    border-bottom: 1px solid #eee; /* Separator line */
    margin-bottom: 10px; /* Space before accordions */
}

#pallet-accordions-container {
    flex-shrink: 1; 
    min-height: 0; /* Allow shrinking if needed, but content will scroll */
    overflow-y: auto; /* If there are many accordions, this container can scroll them */
    /* background-color: lightcyan; */ /* Debug */
}

#pallet-accordions-container .accordion-item {
    border: 1px solid #ddd;
    margin-bottom: 5px;
    border-radius: 4px;
}

#pallet-accordions-container .accordion-header {
    background-color: #f0f0f0;
    padding: 10px 15px;
    cursor: pointer;
    font-weight: bold;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

#pallet-accordions-container .accordion-header::after {
    content: '\25BC'; /* Down arrow */
    font-size: 0.8em;
    margin-left: auto;
    align-self: center;
}

#pallet-accordions-container .accordion-header.active::after {
    content: '\25B2'; /* Up arrow */
}

#pallet-accordions-container .accordion-content {
    padding: 0; /* Padding will be on the inner list */
    display: none; /* Hidden by default */
    border-top: 1px solid #ddd;
}

#pallet-accordions-container .accordion-content.active {
    display: block;
}

#pallet-accordions-container .accordion-content ul {
    max-height: 150px; /* Adjusted */
    overflow-y: auto;   
    list-style-type: none;
    padding: 0;
    margin: 0;
}

#pallet-accordions-container .accordion-content ul li {
    padding: 8px 15px;
    border-bottom: 1px solid #eee;
    cursor: pointer;
}

#pallet-accordions-container .accordion-content ul li:last-child {
    border-bottom: none;
}

#pallet-accordions-container .accordion-content ul li:hover {
    background-color: #f9f9f9;
}

/* Keep existing .highlighted-list-item style, but ensure it targets the new structure */
#pallet-accordions-container .accordion-content ul li.highlighted-list-item {
    background-color: #e0e0e0;
    font-weight: bold;
}

#unplaced-boxes-summary {
    flex-shrink: 0; /* Prevent this from shrinking too much */
    padding-top: 10px; /* Add space above it */
    margin-top: 10px; /* Add space above it */
    border-top: 1px solid #eee; /* Separator line */
    /* background-color: lightpink; */ /* Debug */
}

#unplaced-boxes-summary p, #unplaced-boxes-summary ul {
    margin-top: 0;
    padding: 5px 0;
}

#unplaced-boxes-summary ul {
    max-height: 80px; /* Adjusted */
    overflow-y: auto;
    list-style-type: none;
    padding-left: 0;
}

#unplaced-boxes-summary ul li {
    padding: 5px 0;
    font-size: 0.9em;
}

.control-group {
    margin-bottom: 15px;
}

.control-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
}

.control-group input[type="number"],
.control-group select,
.control-group textarea {
    width: calc(100% - 22px); /* Adjust for padding/border */
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-sizing: border-box;
}

.control-group textarea {
    resize: vertical;
}

button {
    background-color: #3498db;
    color: white;
    padding: 10px 15px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
}

button:hover {
    background-color: #2980b9;
}

/* Loading Overlay */
#loading-overlay {
    position: fixed; /* Cover the whole screen */
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5); /* Semi-transparent black */
    z-index: 1000; /* Ensure it's on top */
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: white;
    text-align: center;
}

.loading-spinner {
    border: 8px solid #f3f3f3; /* Light grey */
    border-top: 8px solid #3498db; /* Blue */
    border-radius: 50%;
    width: 60px;
    height: 60px;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

#loading-overlay p {
    font-size: 1.2em;
    font-style: normal; /* Override italic from other p tags if needed */
}

.accordion-header-line {
    padding: 2px 0;
    font-size: 0.9em;
}

.accordion-header-line strong {
    font-size: 1.1em;
    font-weight: bold;
} 