/* --- Base & Body --- */
html, body {
  height: 100%;
  margin: 0;
  padding: 0;
}
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background-color: #333333;
  color: #333; /* This base color will be overridden by group-card or other specific elements */
}

/* --- Maintenance Mode Styles --- */
.maintenance-mode {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(51, 51, 51, 0.95);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  overflow: auto;
}

.maintenance-content {
  text-align: center;
  padding: 40px;
  background-color: #2a2a2a;
  border-radius: 12px;
  border: 1px solid #444;
  max-width: 400px;
  width: 90%;
  margin: 20px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.maintenance-icon {
  font-size: 48px;
  margin-bottom: 20px;
}

.maintenance-content h2 {
  color: #ffa500;
  margin-bottom: 20px;
  font-size: 24px;
}

.maintenance-content p {
  color: #ccc;
  line-height: 1.6;
  margin-bottom: 15px;
}

.retry-button {
  background-color: #2d74b5;
  color: white;
  border: none;
  padding: 12px 24px;
  border-radius: 6px;
  font-size: 16px;
  cursor: pointer;
  margin-top: 20px;
  transition: background-color 0.3s;
}

.retry-button:hover {
  background-color: #1e5a94;
}

.retry-button:active {
  background-color: #164a7b;
}

/* --- Content Wrapper --- */
.content-wrapper {
  margin: 0 10px;
}

/* --- Top Bar --- */
.top-bar {
  background-color: #2d74b5;
  color: white;
  padding: 10px;
  margin: 10px 0;
  font-weight: bold;
  cursor: pointer;
  border-radius: 4px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.top-bar-indicator {
  margin-left: 10px;
}

/* --- Schedule Header --- */
.schedule-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px;
  margin: 10px 0;
  background-color: #f0f0f0;
  border-bottom: 1px solid #ccc;
  font-weight: bold;
  color: #333;
}
#schedule-date-header {
  flex-grow: 1;
  margin-right: 10px;
}
#schedule-hours-display {
  background-color: #e0eafc;
  color: #333;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 0.9em;
  white-space: nowrap;
  transition: background-color 0.3s ease;
}
#schedule-hours-display.clickable-hours {
  cursor: pointer;
  color: #007aff;
  margin-left: 8px;
}
#schedule-hours-display.clickable-hours:hover {
  text-decoration: underline;
}

/* --- Schedule Content --- */
/* hide everything that leaves the box while it’s animating */
.schedule-container {
  overflow: hidden;       /* or overflow-x: hidden; */
  position: relative;     /* establishes the clipping context */
}

.schedule-content {
  overflow-y: auto;
  padding: 10px 0;
  background-color: #333333;
  will-change: transform;
  touch-action: auto;
  -webkit-overflow-scrolling: touch;
}

/* --- Group Cards --- */
.group-card {
  background-color: #ffffff; /* This will be overridden by JS for group-specific colors */
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  margin: 0 0 12px 0;
  padding: 10px 12px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
  font-weight: bold;
  color: #000000; /* Default text color for group cards before JS applies specific color */
}
.group-header {
  margin: 0 0 8px 0;
  padding-bottom: 5px;
  color: #333; /* This will be overridden by JS for header-specific colors */
  border-bottom: 1px solid #333333; /* Example border color */
  font-size: 1.05em;
}

/* --- Worker Items (Schedule) --- */
/* MODIFIED: Use flexbox for stacking shifts and handling name+keyword on one line */
.worker-item {
  display: flex; /* Flex container for name column and times column */
  align-items: flex-start; /* Align name to top if times stack vertically */
  padding: 6px 0;
  font-size: 0.98em;
  border-bottom: 1px solid #333;
}
.group-card .worker-item:last-child {
  border-bottom: none;
}

.worker-name {
  /* MODIFIED: Allow to grow, but apply overflow to the whole line */
  flex-basis: 0; /* Important for flex-grow to work as intended */
  flex-grow: 1; /* Allow it to take up available space */
  /* max-width: 90%; /* Prevent it from taking too much space, adjust as needed */
  flex-shrink: 1;
  min-width: 0;
  padding-right: 10px; /* Space between name column and time column */
  white-space: nowrap; /* Keep name and keyword on one line */
  overflow: hidden; /* Crucial for ellipsis */
  text-overflow: ellipsis; /* Crucial for ellipsis */
  /* Reverted from display:flex column */
  display: block; /* Default block behavior for span, to contain name and keyword */
}

.worker-name > span:first-child { /* Target the actual name text (first span inside worker-name) */
  /* Remove specific display/overflow. Parent .worker-name now handles nowrap/ellipsis */
  white-space: inherit; /* Inherit from parent, but parent is now nowrap */
  overflow: visible; /* Let parent handle overflow */
  text-overflow: clip; /* Let parent handle overflow */
  display: inline; /* Default inline for text */
}

.worker-optional-keyword {
    font-size: 0.9em; /* Slightly smaller than name */
    font-style: italic;
    color: #7f8c8d;
    margin-left: 4px; /* Space between name and keyword */
    /* Reverted from display:block, no specific nowrap needed here as parent handles it */
    display: inline; /* Keep it inline with the name */
    white-space: nowrap; /* Ensure keyword stays together and truncates if it alone is too long */
    overflow: hidden;
    text-overflow: ellipsis;
}


/* NEW: Container for multiple time shifts */
.worker-times-container {
  /* flex-grow: 1; /* Allow container to take remaining space */
  flex-shrink: 0;
  display: flex;
  flex-direction: column; /* Stack shifts vertically */
  align-items: flex-end; /* Align shifts to the right */
  text-align: right; /* Ensure text is right-aligned */
  min-width: 80px; /* Ensure times column has a minimum width, adjust as needed */
}

/* NEW: Styles for individual shift lines */
.worker-time-line {
    display: block; /* Each shift on its own line */
    width: 100%; /* Take full width */
    margin-bottom: 2px; /* Small space between shifts */
    white-space: nowrap; /* Prevent time ranges from wrapping */
}
.worker-time-line:last-child {
    margin-bottom: 0;
}

.worker-time {
  font-size: 0.9em;
  padding: 1px 3px;
  border-radius: 3px;
}
.highlight-time {
  color: #00aa00;
}
.worker-note-only { /* For notes that replace time, e.g., "Gärtner" */
    font-style: italic;
    color: #777; /* Or inherited group color if appropriate */
    font-size: 0.9em;
    display: block; /* Ensure it's on its own line */
}
.worker-note-inline { /* For notes that are appended to a time range */
    font-size: 0.9em;
    font-style: italic;
    color: #777; /* Or inherited group color if appropriate */
    margin-left: 5px; /* Small space after time before note */
}


.worker-item.worker-absent {
  opacity: 0.8;
  color: #cccccc; /* Lighter grey for better readability */
}
.worker-item.worker-absent .worker-name {
  text-decoration: none; /* No line-through on name itself */
  /* This ensures the whole name area isn't struck through, only the text content */
  color: #cccccc; /* Ensure name is readable */
}
.worker-item.worker-absent .worker-name > span:first-child { /* Target the actual name text */
  text-decoration: line-through; /* Apply line-through only to the name */
}

.worker-absence-keyword {
  /* Positioned within the flex context */
  flex-grow: 1; /* Take remaining space */
  text-align: right;
  font-style: italic;
  color: #ff9999; /* Lighter red for better visibility */
  padding: 0 5px 2px 0;
  white-space: nowrap; /* Prevent keyword from wrapping if possible */
  overflow: hidden;
  text-overflow: ellipsis;
}

/* --- Task Drawer --- */
#task-view {
  position: fixed;
  bottom: 0;
  left: 10px;
  right: 10px;
  background-color: transparent;
  z-index: 1000;
  border-radius: 4px 4px 0 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: 80vh; /* Added max-height to prevent covering whole screen */
}
#task-header {
  font-weight: bold;
  padding: 10px 15px;
  background-color: #2c2c2e;
  color: #ffffff;
  cursor: pointer;
  position: relative;
  user-select: none;
  border-bottom: 1px solid #4a4a4c;
  transition: background-color 0.3s ease;
  flex-shrink: 0; /* Prevent header from shrinking */
}
#task-header::after {
  content: '▲';
  position: absolute;
  right: 15px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.8em;
  color: #a0a0a5;
  transition: transform 0.3s ease-out;
}
#task-header.collapsed::after {
  content: '▼'; /* Changed from ▼ to ▲ when collapsed, and vice versa */
}
#task-content {
  overflow-y: auto;
  flex-grow: 1;
  padding: 5px 0; /* Add some vertical padding */
  margin: 0;
  background-color: #333333;
  color: #e0e0e0;
  -webkit-overflow-scrolling: touch;
}
#task-content.collapsed {
  overflow: hidden;
  flex-grow: 0; /* Don't grow when collapsed */
  padding: 0; /* No padding when collapsed */
}

/* --- Task Item Styling (Modified for Grid) --- */
.task-item {
  display: grid;
  grid-template-columns: minmax(12ch, auto) 1fr;
  gap: 0 0.75em; /* No row gap, column gap for spacing */
  align-items: start; /* Align tops of time and description */
  padding: 8px 8px; /* Vertical padding inside item, horizontal padding via grid */
  font-size: 0.9em;
  border-bottom: 1px solid #3a3a3c;
  line-height: 1.0; /* Improve readability */
}

#task-content .task-item:last-child {
  border-bottom: none;
}

.task-time {
  /* Grid Column 1 */
  font-weight: 500; /* Slightly bolder */
  white-space: nowrap;
  color: #f5f5f7;
  text-align: left; /* Align time text */
}

.task-desc-details {
    /* Grid Column 2 - This holds description and details */
    /* No specific grid styles needed, just flows into column 2 */
    /* Text color is inherited from #task-content */
}

.task-details {
  /* Now inline within task-desc-details */
  display: inline; /* Changed from block */
  font-size: 0.9em; /* Slightly smaller */
  color: #a0a0a5;
  margin-left: 0.5em; /* Space between description and details */
}

/* --- Handle Placeholders --- */
.task-item.loading-placeholder,
.task-item.error-message,
.task-item.info-placeholder {
    display: block; /* Override grid display */
    grid-template-columns: none; /* Reset columns */
    text-align: center; /* Center placeholder text */
    padding: 10px 15px; /* Restore padding */
    gap: 0; /* Reset gap */
}

/* --- Worker Drawer (shared with task, but initially off-screen) --- */
.task-panel {
  position: fixed;
  bottom: -100%;
  left: 10px;
  right: 10px;
  background-color: #1c1c1e;
  color: #e0e0e0;
  border-top: 1px solid #4a4a4c;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  max-height: 80vh;
  border-radius: 4px 4px 0 0;
  overflow: hidden;
  box-shadow: 0 -5px 15px rgba(0,0,0,0.3);
}
.task-panel .panel-header {
  padding: 10px 15px;
  font-weight: bold;
  background-color: #2c2c2e;
  position: relative;
}
.task-panel .close-btn {
  position: absolute;
  right: 15px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: #a0a0a5;
  font-size: 1.2em;
  cursor: pointer;
}
.task-panel .close-btn:hover {
  color: #fff;
}
.task-panel .panel-content {
  overflow-y: auto;
  flex-grow: 1;
  padding: 0;
  background-color: #333333;
}

/* NEW/MODIFIED: Worker hours list items right-alignment */
/* Target the span containing the hours directly or make its container flex/grid */
#worker-hours-list .worker-item {
    display: flex; /* Ensure flex behavior */
    justify-content: space-between; /* Push items to ends */
    align-items: center; /* Vertically align */
    padding: 8px 15px; /* Add some padding */
    border-bottom: 1px solid #4a4a4c;
    font-size: 0.95em;
    color: #e0e0e0;
}

#worker-hours-list .worker-item:last-child {
    border-bottom: none;
}

/* Target the hours span specifically within the worker-item */
#worker-hours-list .worker-item > span:last-child { /* Assuming hours span is the last child */
    text-align: right;
    margin-left: auto; /* Push it to the right */
}
#worker-hours-list .worker-item label { /* Ensure label takes space for checkbox + name */
    flex-grow: 1;
    display: flex;
    align-items: center;
}
#worker-hours-list .worker-item input[type="checkbox"] {
    margin-right: 8px; /* Space between checkbox and name */
}


.task-panel .panel-footer {
  padding: 8px 16px;
  background-color: #2c2c2e;
  padding-bottom: 25px;
  font-weight: bold;
}

/* --- Modal Styles --- */
/* --- Warning Modal (styled like task‑panel) --- */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 10px;
  right: 10px;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.6);
  z-index: 1200;
  display: flex;
  align-items: flex-end;     /* slide up from bottom */
  justify-content: center;
}

.modal-content {
  width: 100%;
  max-width: 400px;
  max-height: 80vh;
  background-color: #1c1c1e;    /* same as .task-panel */
  color: #e0e0e0;             /* match panel text */
  border-top-left-radius: 4px;
  border-top-right-radius: 4px;
  box-shadow: 0 -5px 15px rgba(0,0,0,0.3);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* header matches panel‑header */
.modal-header {
  padding: 10px 15px;
  background-color: #FF0000;
  font-weight: bold;
  color: #ffffff;
  display: flex;
  align-items: center;
  position: relative;
}

/* close button like panel .close-btn */
.modal-close-button {
  position: absolute;
  right: 15px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  font-size: 1.2em;
  color: #FFFFFF;
  cursor: pointer;
}
.modal-close-button:hover {
  color: #fff;
}

/* body matches panel‑content */
.modal-body {
  overflow-y: auto;
  flex-grow: 1;
  padding: 15px;
  background-color: #333333;
  color: #e0e0e0;
}

/* --- Week List --- */
/* Week List Highlighting */
.week-list-container {
  overflow-y: auto;
  flex-grow: 1;
  border-top: 1px solid #4a4a4c;
}

.week-list-item {
  padding: 8px 15px;
  font-size: 0.95em;
  color: #e0e0e0;                /* match panel text color */
  border-bottom: 1px solid #4a4a4c;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: background-color 0.2s ease, color 0.2s ease; /* Add transition for smoothness */
}

.week-list-item:last-child {
  border-bottom: none;
}

.week-list-item:hover {
  background-color: #2c2c2e;
}

/* Styles for the selected week item */
.week-list-item.selected {
  background-color: #007aff; /* A prominent blue */
  color: #ffffff; /* White text for contrast */
  font-weight: bold; /* Make it stand out */
}

/* Ensure children inherit color from selected parent */
.week-list-item.selected .week-item-kw,
.week-list-item.selected .week-item-range {
  color: inherit; /* Inherit the white color */
}


.worker-adjusted {
  color: #777;
  font-style: italic;
  font-size: 0.9em;
  margin-left: 4px;
}

.week-list-item {
  /* keep your existing padding, border, etc. */
  color: #e0e0e0;             /* panel text color */
  font-size: 0.98em;           /* match .worker-item font-size */
}

.week-item-kw,
.week-item-range {
  color: inherit;              /* inherit that #e0e0e0 */
  font-size: inherit;          /* same size as the parent .week-list-item */
}

/* In your main schedule display CSS file */
.task-item.holiday-task {
  font-weight: bold;
  border-left: 3px solid #fbc02d; /* Yellow border */
}

.task-item.holiday-task .task-time {
  color: #c77a07; /* Darker yellow/orange for time text */
}
