:root {
    --cell-base-height: 18px;
    --cell-base-font-size: 8px; /* Minimum font */
    --cell-padding: 2px;
}

body {
    font-family: sans-serif;
    margin: 20px;
    background-color: #f4f4f4;
}

h1, h2, h3 {
    text-align: center;
    color: #333;
}

h1 {
    font-size: 0.75em; /* Reduce heading size */
}

.controls, .data-management { /* Apply flex to these two only */
    margin-bottom: 20px;
    padding: 10px 15px; /* Adjust padding slightly */
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    display: flex; /* Use Flexbox */
    align-items: center; /* Vertically align items */
    justify-content: space-between; /* Space out children */
    gap: 15px; /* Add some space between items */
}

.report-controls { /* Keep report-controls separate, as it was before */
     margin-bottom: 20px;
     padding: 15px;
     background-color: #fff;
     border-radius: 8px;
     box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
     text-align: center;
}

/* Remove rules for .controls-header, .data-management-header */

.controls-content, .data-management-content { /* Style for the content divs */
    flex-grow: 1; /* Allow content to take up space */
    text-align: center; /* Center the content within this div */
}


.controls-content.minimized,
.data-management-content.minimized {
    display: none; /* Hide content when minimized */
}

.controls h3, .data-management h3 { /* Target h3 directly inside flex container */
     margin: 0; /* Remove default margin */
     white-space: nowrap; /* Prevent wrapping */
}

.controls label { /* Keep label margin */
    margin: 0 10px;
}
/* Remove rule for .controls-header h3, .data-management-header h3 */

button {
    padding: 8px 15px;
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    margin: 5px;
    transition: background-color 0.2s ease;
}

.toggle-settings-btn, .toggle-data-btn {
    padding: 5px 10px; /* Smaller padding */
    background-color: #6c757d; /* Distinct color */
    margin: 0; /* Remove default button margin */
    flex-shrink: 0; /* Prevent button from shrinking */
}
.toggle-settings-btn:hover, .toggle-data-btn:hover {
     background-color: #5a6268;
}

button:hover {
    background-color: #0056b3;
}

#delete-day-button, #delete-all-button {
     background-color: #dc3545;
}
#delete-day-button:hover, #delete-all-button:hover {
     background-color: #c82333;
}


.table-container {
    overflow-x: auto; /* Allows scrolling if table is too wide */
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    margin: 0 auto; /* Center the container */
}

@media (min-width: 768px) {
    .table-container {
        max-width: 600px; /* Set max width for desktop */
    }
}

#time-table {
    width: 100%;
    border-collapse: collapse;
    /* table-layout: fixed; */ /* Changed to auto to allow flexible column widths */
    table-layout: auto;
}

#time-table th, #time-table td { /* Applies to header cells and time-slot cells (td) */
    border: 1px solid #ddd; /* Base border - KEEP ON TD */
    padding: 0; /* Critical: No padding on TD to allow inner div to fill */
    text-align: center; /* Keep text-align here? Or move to inner? Keep here for header cells. */
    height: var(--cell-base-height); /* KEEP height on TD */
    /* font-size: 12px; */ /* Removed, now handled by .time-slot-inner */
    vertical-align: middle; /* Ensure TD alignment is middle */
}

#time-table th {
    background-color: #e9ecef;
    padding: 8px 5px; /* Add padding back to headers */
    font-size: 14px;
}

#time-table tbody tr td:first-child {
    font-weight: bold;
    background-color: #f8f9fa;
    font-size: 13px; /* Slightly smaller header */
    padding: 4px 5px; /* Add padding back to time column */
    vertical-align: middle;
    width: 55px; /* Explicit width for the time column */
    min-width: 55px; /* Ensure it doesn't shrink below this */
    /* height: var(--cell-base-height); */ /* Height is already set on td above */
}

/* .time-slot IS THE TD ELEMENT */
.time-slot {
    border: 1px solid #ddd; /* It inherits border from TD rule, but state borders below will override */
    position: relative; /* Needed for potential future absolute positioning inside */
    padding: 0; /* Ensure no padding on the TD */
}

/* .time-slot-inner IS THE DIV INSIDE THE TD */
.time-slot-inner {
    display: block; /* Make it a block to fill the TD */
    width: 100%;
    height: 100%; /* Inherit height from TD */
    cursor: pointer;
    transition: background-color 0.3s ease; /* Only background color transition needed */
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    font-size: var(--cell-base-font-size); /* Use variable */
    line-height: var(--cell-base-height); /* Helps vertically center simple text */
    padding: 0 var(--cell-padding); /* Padding L/R only */
    box-sizing: border-box; /* Include padding in height */
    background-color: transparent; /* Default background */
}

/* Change hover target to the inner div */
.time-slot .time-slot-inner:hover {
    background-color: #e0e0e0 !important; /* Use !important to override inline style */
}

/* Keep row hover on TD or change to innerDiv? Let's try TD first. */
tr.row-hover td.time-slot {
    /* Maybe remove this if visually distracting with inner div background? */
    /* background-color: #f0f0f0 !important; /* Slightly lighter grey */
    /* If we want innerDiv to change color on row hover: */
    /* background-color: transparent !important; /* Reset TD background */
}
/* Make innerDiv slightly grey on row hover */
tr.row-hover td.time-slot .time-slot-inner {
    background-color: #f0f0f0 !important; /* Light grey for inner div on row hover */
}

/* Border Colors/Styles for Time State - Overriding base border */
/* Border Styles for Time State - Apply to the TD (.time-slot) directly */
/* We need to override the base border */
.time-slot {
    border: 1px solid #ddd; /* Reiterate base border */
}
.time-slot.past {
      border-color: #ff8a80; /* A slightly stronger Light Red */
      border-width: 2px;
      border-style: solid;
}
.time-slot.future {
    border-color: #90ee90; /* Light Green */
    border-width: 2px;
    border-style: solid;
}
.time-slot.current {
    border-color: orange;
    border-width: 3px;
    border-style: solid;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(255, 165, 0, 0.7);
    }
    70% {
        box-shadow: 0 0 0 5px rgba(255, 165, 0, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(255, 165, 0, 0);
    }
}

/* Modal Styles */
.modal {
    display: none; /* Hidden by default */
    position: fixed; /* Stay in place */
    z-index: 1; /* Sit on top */
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto; /* Enable scroll if needed */
    background-color: rgba(0,0,0,0.4); /* Black w/ opacity */
}

.modal-content {
    background-color: #fefefe;
    margin: 15% auto; /* 15% from the top and centered */
    padding: 20px;
    border: 1px solid #888;
    width: 80%; /* Could be more or less, depending on screen size */
    max-width: 500px;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.close-button {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
}

.close-button:hover,
.close-button:focus {
    color: black;
    text-decoration: none;
    cursor: pointer;
}

.modal-content label {
    display: block;
    margin-top: 10px;
    font-weight: bold;
}

.modal-content input[type="text"],
.modal-content input[type="time"],
.modal-content textarea,
.modal-content select {
    width: calc(100% - 22px); /* Account for padding/border */
    padding: 10px;
    margin-top: 5px;
    border: 1px solid #ccc;
    border-radius: 4px;
}
.modal-content input[type="color"] {
     padding: 2px;
     height: 30px;
     vertical-align: middle;
     margin-left: 5px;
}


.modal-content button {
    margin-top: 15px;
}

#modal-clear-button {
    background-color: #ffc107;
    color: #333;
}
#modal-clear-button:hover {
    background-color: #e0a800;
}


.error-message {
    color: red;
    font-size: 0.9em;
    margin-top: 10px;
}

/* Report Styles */
#report-section {
    background-color: #fff;
    padding: 20px;
    margin-top: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.report-item {
    margin-bottom: 10px;
    padding: 10px;
    border: 1px solid #eee;
    border-radius: 4px;
}

.report-item span:first-child {
    font-weight: bold;
    cursor: pointer; /* Indicate it's clickable */
    display: inline-block; /* Allows padding/margin */
    padding: 5px;
    border-radius: 3px;
    color: white; /* Text color for label */
    min-width: 80px; /* Minimum width for label */
    text-align: center;
}
.report-item span:first-child:hover {
    opacity: 0.8;
}

.report-notes {
    margin-top: 8px;
    padding-left: 15px;
    font-size: 0.9em;
    border-left: 3px solid #eee;
}
.report-notes div {
    margin-bottom: 5px;
}

/* Tooltip Styles */
.tooltip {
    position: absolute; /* Position relative to the viewport or nearest positioned ancestor */
    display: none; /* Hidden by default */
    background-color: rgba(0, 0, 0, 0.8); /* Dark semi-transparent background */
    color: white;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 12px;
    white-space: pre-wrap; /* Allow line breaks from \n */
    z-index: 1000; /* Ensure it's on top */
    pointer-events: none; /* Prevent tooltip from interfering with mouse events */
    max-width: 250px; /* Prevent it from becoming too wide */
}