/* === HEADER === */
.app-header {
  background: var(--color-bg-header);
  color: var(--color-text-on-dark);
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.header-logo {
  height: 36px;
}

.header-title {
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-bold);
}

.header-subtitle {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-kw {
  font-size: var(--font-size-md);
  font-weight: var(--font-weight-bold);
  margin: 0 12px;
  white-space: nowrap;
}

.nav-btn {
  background: transparent;
  color: white;
  border: 1.5px solid rgba(255,255,255,0.4);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  cursor: pointer;
  font-family: var(--font-base);
  font-size: var(--font-size-sm);
}
.nav-btn:hover {
  border-color: var(--color-accent-light);
  color: var(--color-accent-light);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-actions .nav-btn {
  font-size: var(--font-size-xs);
}

/* === GRID CONTAINER === */
.grid-container {
  overflow-x: auto;
  overflow-y: auto;
  max-height: calc(100vh - 60px);
}

.plan-grid {
  display: grid;
  min-width: max-content;
  border-collapse: collapse;
}

/* === RESOURCE COLUMN (sticky left) === */
.grid-resource-header,
.grid-resource-cell {
  position: sticky;
  left: 0;
  z-index: 10;
  background: var(--color-primary);
  color: var(--color-text-on-dark);
  padding: 6px 12px;
  font-size: var(--font-size-sm);
  white-space: nowrap;
  border-bottom: 1px solid var(--color-primary-light);
  min-width: 180px;
}

.grid-resource-header {
  z-index: 20;
  background: var(--color-primary-dark);
  font-weight: var(--font-weight-bold);
  font-size: var(--font-size-xs);
  text-transform: uppercase;
  letter-spacing: 1px;
  position: sticky;
  top: 0;
}

.grid-group-header {
  background: var(--color-primary-light);
  color: var(--color-text-on-dark);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-bold);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  padding: 8px 12px;
  grid-column: 1 / -1;
  border-bottom: 1px solid var(--color-primary);
}

/* === DATE HEADERS === */
.grid-date-header {
  text-align: center;
  padding: 4px 2px;
  font-size: var(--font-size-xs);
  border-bottom: 1px solid var(--color-border);
  border-left: 1px solid var(--color-border);
  background: var(--color-bg-card);
  position: sticky;
  top: 0;
  z-index: 15;
}

.grid-date-header.weekend {
  background: var(--color-weekend-header);
  color: var(--color-text-secondary);
}

.date-label {
  font-weight: var(--font-weight-bold);
  display: block;
}

.holiday-label {
  display: block;
  font-size: 9px;
  color: #c0392b;
  font-weight: var(--font-weight-bold);
  line-height: 1.2;
}

.date-day {
  font-size: 10px;
  color: var(--color-text-muted);
}

.shift-headers {
  display: flex;
  justify-content: center;
  gap: 2px;
  margin-top: 2px;
}

.shift-label {
  font-size: 10px;
  font-weight: var(--font-weight-bold);
  color: var(--color-text-muted);
  width: 28px;
  text-align: center;
}

/* === GRID CELLS === */
.grid-cell {
  border-bottom: 1px solid var(--color-border);
  border-left: 1px solid var(--color-border);
  background: var(--color-bg-card);
  min-height: 36px;
  display: flex;
  align-items: stretch;
}

.grid-cell.weekend {
  background: var(--color-weekend-bg);
}

.shift-cell {
  min-width: 52px;
  padding: 2px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  flex: 1;
  border-right: 1px solid rgba(0,0,0,0.05);
}

.shift-cell:last-child {
  border-right: none;
}

.shift-cell:hover {
  background: rgba(0,0,0,0.04);
}

.weekend .shift-cell {
  min-width: 36px;
}

/* === ASSIGNMENT CHIPS === */
.assignment-chip {
  border-radius: var(--radius-sm);
  padding: 3px 6px;
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-bold);
  color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,0.4);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  line-height: 1.3;
}

/* === STATUS QUICK BUTTONS === */
.status-buttons {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.status-btn {
  padding: 6px 14px;
  border: 2px solid transparent;
  border-radius: var(--radius-sm);
  color: #fff;
  font-family: var(--font-base);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-bold);
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
}

.status-btn:hover {
  opacity: 0.85;
  transform: scale(1.05);
}

.status-btn.active {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px white, 0 0 0 4px var(--color-primary);
}

.assignment-note {
  font-size: 10px;
  font-weight: normal;
  opacity: 0.85;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}

/* === STATUS COLORS (fixed) === */
.status-krank { background: #c0392b !important; }
.status-ausfall { background: #e74c3c !important; }
.status-urlaub { background: #f39c12 !important; }
.status-versetzt { background: #7f8c8d !important; }

/* === VIEW TOGGLE === */
.view-toggle {
  transition: background 0.15s, color 0.15s;
}
.view-toggle.active {
  background: var(--color-accent);
  color: white;
  border-color: var(--color-accent);
}

/* === 3-MONTH OVERVIEW === */
.quarter-grid {
  display: grid;
  min-width: max-content;
}

.quarter-month-label {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--color-primary-dark);
  color: var(--color-text-on-dark);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-bold);
  text-align: center;
  padding: 6px 2px;
  border-left: 1px solid var(--color-primary-light);
}

.quarter-kw-label {
  position: sticky;
  top: 24px;
  z-index: 19;
  background: var(--color-bg-card);
  font-size: 9px;
  color: var(--color-text-muted);
  text-align: center;
  padding: 2px 0;
  border-left: 1px solid var(--color-border);
  border-bottom: 1px solid var(--color-border);
  cursor: pointer;
}

.quarter-kw-label:hover {
  background: var(--color-accent-light);
  color: white;
}

.quarter-day-header {
  position: sticky;
  top: 42px;
  z-index: 18;
  background: var(--color-bg-card);
  font-size: 8px;
  color: var(--color-text-muted);
  text-align: center;
  padding: 1px 0;
  border-left: 1px solid rgba(0,0,0,0.04);
  border-bottom: 1px solid var(--color-border);
  min-width: 18px;
}

.quarter-day-header.weekend,
.quarter-day-header.holiday {
  background: var(--color-weekend-header);
}

.quarter-day-header.month-start {
  border-left: 2px solid var(--color-border-strong);
}

.quarter-resource-header {
  position: sticky;
  left: 0;
  top: 0;
  z-index: 25;
  background: var(--color-primary-dark);
  color: var(--color-text-on-dark);
  padding: 6px 10px;
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-bold);
  min-width: 160px;
  border-bottom: 1px solid var(--color-primary-light);
}

.quarter-resource-cell {
  position: sticky;
  left: 0;
  z-index: 10;
  background: var(--color-primary);
  color: var(--color-text-on-dark);
  padding: 2px 10px;
  font-size: 11px;
  white-space: nowrap;
  border-bottom: 1px solid var(--color-primary-light);
  min-width: 160px;
  display: flex;
  align-items: center;
}

.quarter-group-header {
  background: var(--color-primary-light);
  color: var(--color-text-on-dark);
  font-size: 10px;
  font-weight: var(--font-weight-bold);
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 5px 10px;
  grid-column: 1 / -1;
  border-bottom: 1px solid var(--color-primary);
}

.quarter-cell {
  min-width: 18px;
  height: 22px;
  border-bottom: 1px solid rgba(0,0,0,0.06);
  border-left: 1px solid rgba(0,0,0,0.04);
  cursor: pointer;
  position: relative;
}

.quarter-cell.weekend,
.quarter-cell.holiday {
  background: var(--color-weekend-bg);
}

.quarter-cell.month-start {
  border-left: 2px solid var(--color-border-strong);
}

.quarter-cell:hover {
  outline: 2px solid var(--color-accent);
  outline-offset: -2px;
  z-index: 5;
}

.quarter-cell .q-chip {
  position: absolute;
  inset: 1px;
  border-radius: 2px;
  opacity: 0.9;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 8px;
  font-weight: 700;
  line-height: 1;
  overflow: hidden;
}

.quarter-cell .q-chip:hover {
  opacity: 1;
}

/* Legend for quarter view */
.quarter-legend {
  display: flex;
  gap: 12px;
  padding: 8px 16px;
  background: var(--color-bg-card);
  border-bottom: 1px solid var(--color-border);
  flex-wrap: wrap;
  align-items: center;
  font-size: var(--font-size-xs);
  color: var(--color-text-secondary);
}

.quarter-legend-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

.quarter-legend-swatch {
  width: 12px;
  height: 12px;
  border-radius: 2px;
}

/* Tooltip for quarter cells */
.q-tooltip {
  position: fixed;
  background: var(--color-primary);
  color: white;
  padding: 6px 10px;
  border-radius: var(--radius-md);
  font-size: var(--font-size-xs);
  z-index: 5000;
  pointer-events: none;
  box-shadow: var(--shadow-md);
  white-space: nowrap;
}

/* === TEXTAREA AUTO-RESIZE === */
#noteInput {
  width: 100%;
  min-height: 36px;
  max-height: 200px;
  padding: 8px 10px;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  font-family: var(--font-base);
  font-size: var(--font-size-sm);
  resize: vertical;
  overflow-y: auto;
  box-sizing: border-box;
}

/* === PHOTO SECTION === */
.photo-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.photo-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.photo-thumb {
  position: relative;
  width: 72px;
  height: 72px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--color-border);
}

.photo-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  cursor: pointer;
}

.photo-thumb .photo-delete {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 20px;
  height: 20px;
  background: rgba(0,0,0,0.6);
  color: #fff;
  border: none;
  border-radius: 50%;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.photo-upload-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: var(--color-bg-page);
  border: 1.5px dashed var(--color-border-strong);
  border-radius: var(--radius-md);
  font-family: var(--font-base);
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: background 0.15s;
}

.photo-upload-btn:hover {
  background: var(--color-border);
}

/* Photo indicator in week view */
.photo-indicator {
  display: inline-block;
  width: 12px;
  height: 12px;
  vertical-align: middle;
  margin-left: 3px;
  opacity: 0.8;
}

/* === MODAL / DIALOG === */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-overlay.hidden { display: none; }

.modal {
  background: var(--color-bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 24px;
  width: 90%;
  max-width: 440px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-title {
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-bold);
  margin-bottom: 4px;
}

.modal-subtitle {
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
  margin-bottom: 20px;
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-bold);
  color: var(--color-text-secondary);
  margin-bottom: 4px;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  font-family: var(--font-base);
  font-size: var(--font-size-sm);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--color-accent);
}

.shift-toggle {
  display: flex;
  gap: 8px;
}

.shift-toggle button {
  flex: 1;
  padding: 8px;
  border: 1.5px solid var(--color-border);
  background: var(--color-bg-card);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: var(--font-base);
  font-weight: var(--font-weight-bold);
  font-size: var(--font-size-sm);
}

.shift-toggle button.active {
  background: var(--color-accent);
  color: white;
  border-color: var(--color-accent);
}

/* Color palette picker */
.color-palette {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.color-swatch {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: 2px solid transparent;
  transition: transform 0.1s;
}

.color-swatch:hover { transform: scale(1.15); }
.color-swatch.active { border-color: var(--color-primary); box-shadow: 0 0 0 2px white, 0 0 0 4px var(--color-primary); }

/* Repeat section */
.repeat-section {
  border-top: 1px solid var(--color-border);
  padding-top: 12px;
}

.repeat-toggle {
  cursor: pointer;
  font-weight: var(--font-weight-bold);
  color: var(--color-accent);
  font-size: var(--font-size-sm);
  user-select: none;
}

.repeat-content { display: none; margin-top: 12px; }
.repeat-content.visible { display: block; }

.weekday-checkboxes {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.weekday-checkboxes label {
  display: flex;
  align-items: center;
  gap: 3px;
  font-size: var(--font-size-sm);
  cursor: pointer;
}

.modal-actions {
  display: flex;
  justify-content: space-between;
  margin-top: 20px;
  gap: 8px;
}

/* Autocomplete */
.autocomplete-wrapper {
  position: relative;
}

.autocomplete-list {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: white;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  max-height: 200px;
  overflow-y: auto;
  z-index: 2000;
  display: none;
}

.autocomplete-list.visible { display: block; }

.autocomplete-item {
  padding: 8px 10px;
  cursor: pointer;
  font-size: var(--font-size-sm);
  display: flex;
  align-items: center;
  gap: 8px;
}

.autocomplete-item:hover {
  background: var(--color-bg-page);
}

.autocomplete-color {
  width: 14px;
  height: 14px;
  border-radius: 2px;
  flex-shrink: 0;
}

/* Connection status indicator */
.connection-status {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 4px;
}
.connection-status.connected { background: #2ecc71; }
.connection-status.disconnected { background: #e74c3c; }
