/* Success banner style for showSuccessBanner */
.error-banner.success {
  background: #2ecc40;
  color: #fff;
  border: 1px solid #27ae60;
}
/* ========================================================================== */
/*                                   Global                                   */
/* ========================================================================== */
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  background: #fff;
  color: #222;
}

/* Visually-hidden helper for accessibility */
.visually-hidden {
  position: absolute !important;
  height: 1px; width: 1px;
  overflow: hidden;
  clip: rect(1px, 1px, 1px, 1px);
  white-space: nowrap;
  border: 0; padding: 0; margin: -1px;
}

/* ========================================================================== */
/*                                Header Layout                               */
/* ========================================================================== */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 1100px;
  margin: 8px auto 12px auto;
  gap: 16px;
  padding: 6px 8px;
  box-sizing: border-box;
  width: 100%;
}

/* Left side stacks title above prev/next */
.header-left {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
}

/* Title */
#title, .title {
  font-family: "Inter", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  font-size: 1.9em;
  font-weight: 700;
  text-transform: uppercase;
  margin: 0;
  color: #222;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Prev/Next below title */
.nav-bottom {
  display: flex;
  gap: 8px;
  align-items: center;
}
.nav-bottom button {
  background: #eee;
  border: 1px solid #ccc;
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.92em;
}

/* Right side controls */
.header-right { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.header-right #print,
.header-right #export-calendar,
.header-right #submit-changes {
  background: #eee;
  border: 1px solid #ccc;
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.92em;
  transition: background 0.15s ease;
}
.header-right #submit-changes {
  background: #cfe2ff;
  border-color: #b6d4fe;
  color: #084298;
  font-weight: 600;
}
.header-right #submit-changes:hover {
  background: #b6d4fe;
}
.header-right #export-calendar {
  background: #d4edda;
  border-color: #c3e6cb;
  color: #155724;
  font-weight: 600;
}
.header-right #export-calendar:hover {
  background: #c3e6cb;
}
.k-toggle-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.95em;
  color: #333;
}

/* Toggle switch */
.switch {
  position: relative;
  display: inline-block;
  width: 46px;
  height: 26px;
}
.switch input { display: none; }
.slider {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: #ddd;
  border-radius: 26px;
  transition: background 0.18s ease;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.6);
}
.slider:before {
  content: "";
  position: absolute;
  height: 20px;
  width: 20px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.18s ease;
  box-shadow: 0 2px 4px rgba(0,0,0,0.12);
}
.switch input:checked + .slider { background: #0078d7; }
.switch input:checked + .slider:before { transform: translateX(20px); }

/* ========================================================================== */
/*                              Error banner                                  */
/* ========================================================================== */
.error-banner {
  max-width: 900px;
  margin: 6px auto;
  padding: 8px 12px;
  border: 1px solid #e5a1a1;
  background: #fff2f2;
  color: #7a1d1d;
  border-radius: 6px;
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: flex-start;
  box-sizing: border-box;
}
.error-btn {
  margin-left: 8px;
  background: #fff;
  border: 1px solid #e0b4b4;
  padding: 6px 8px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9em;
}

/* ========================================================================== */
/*                              Assignment / Calendar                         */
/* ========================================================================== */
.weekday-row {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  max-width: 900px;
  margin: 0 auto;
  text-align: center;
  font-weight: bold;
  gap: 0;
  box-sizing: border-box;
  overflow: hidden;
}
.weekday-row div { border: 1px solid #ccc; padding: 6px 8px; background: #f5f5f5; box-sizing: border-box; }

.calendar {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  max-width: 900px;
  margin: 0 auto;
  gap: 0;
  box-sizing: border-box;
  -webkit-user-select: none;
  grid-auto-rows: minmax(120px, auto);
  /* keep the calendar from sitting flush against the bottom when cells expand —
     add padding roughly equal to one date-box height (min-height of .day) */
  padding-bottom: 120px;
}

.day {
  border: 1px solid #ccc;
  min-height: 120px;
  padding: 8px;
  position: relative;
  box-sizing: border-box;
  min-width: 0;
  background: #fff;
  padding-bottom: 48px;
}

.day.other-month .day-number {
  color: #9aa4ad;
  opacity: 0.8;
  font-weight: 600;
}
.day-number { font-weight: 700; font-size: 0.95em; }
.day.weekend { background: #eef6ff; }

/* subdued add button */
.add-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: none;
  background: rgba(0,0,0,0.03);
  color: #666;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 400;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  transition: background 0.12s ease, transform 0.06s ease, opacity 0.12s ease;
  opacity: 0.95;
}
.add-btn:hover { background: rgba(0,0,0,0.05); opacity: 1; }
.add-btn:active { transform: translateY(1px); }

/* shift container (imported JSON) positioned bottom-left */
.shift-container {
  position: absolute;
  bottom: 8px;
  left: 8px;
  right: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: flex-start;
  max-height: 64px;
  overflow: hidden;
  pointer-events: auto;
  z-index: 0;
}
.shift-container.expanded { max-height: none; overflow: visible; }

.shift-label {
  font-size: 0.68em;
  font-weight: 400;
  color: #555;
  background: transparent;
  padding: 0;
  border-radius: 0;
  border: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.shift-label.k-off { font-style: italic; color: #666; }
.shift-label.k-shift { color: #444; font-weight: 400; }

.shift-label.more-label {
  background: rgba(0,0,0,0.06);
  padding: 3px 6px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 700;
  font-size: 0.72em;
}

/* assignments (Nonnie/Sophia/Note) */
.assignment {
  border-radius: 6px;
  font-size: 0.9em;
  margin: 4px 0;
  padding: 6px 8px;
  display: block;
  user-select: none;
  -webkit-user-select: none;
  position: relative;
  z-index: 2;
  line-height: 1.05;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.assignment.nonnie { background: #c8e6c9; color: #000; font-weight: 800; }
.assignment.sophia { background: #bbdefb; color: #000; font-weight: 800; }
.assignment.note-card { background: #fff9c4; border: 1px solid #f0e68c; color: #222; }
.assignment.hidden-assignment { display: none; }
.day.expanded .assignment.hidden-assignment { display: block; }

/* ========================================================================== */
/*                          Submit Changes Modal                              */
/* ========================================================================== */
.submit-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10001;
}
.submit-modal-content {
  background: #fff;
  padding: 24px;
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
  max-width: 400px;
  width: 90%;
}
.submit-modal-content h3 {
  margin: 0 0 12px 0;
  font-size: 1.3em;
}
.submit-modal-content p {
  margin: 0 0 16px 0;
  color: #666;
}
#submitter-name {
  width: 100%;
  padding: 10px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 1em;
  box-sizing: border-box;
  margin-bottom: 16px;
}
.submit-modal-buttons {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}
.submit-btn {
  background: #0078d7;
  color: #fff;
  border: none;
  padding: 10px 20px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
}
.submit-btn:hover {
  background: #005a9e;
}
.cancel-btn {
  background: #eee;
  border: 1px solid #ccc;
  padding: 10px 20px;
  border-radius: 6px;
  cursor: pointer;
}
.cancel-btn:hover {
  background: #ddd;
}

/* ========================================================================== */
/*                              Day menu (popover)                            */
/* ========================================================================== */
.day-menu {
  position: fixed;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  z-index: 10000;
  min-width: 200px;
  transform-origin: top left;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s ease, transform 0.12s ease;
}
.day-menu[aria-hidden="false"] { opacity: 1; pointer-events: auto; transform: scale(1); }
.day-menu .menu-btn {
  border: none;
  background: transparent;
  text-align: left;
  padding: 8px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 700;
}
.day-menu .menu-btn:hover { background: #f5f5f5; }
.day-menu .menu-btn.nonnie { color: #0b7a0b; font-weight: 800; }
.day-menu .menu-btn.sophia { color: #0b57a6; font-weight: 800; }
.day-menu .menu-btn.note-card { color: #a07400; font-weight: 700; }
.day-menu .menu-btn.cancel { color: #666; font-weight: 600; }

/* note editor form */
.note-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
#note-input {
  min-width: 180px;
  max-width: 360px;
  font-size: 0.95em;
  padding: 8px;
  border: 1px solid #ddd;
  border-radius: 6px;
  resize: vertical;
  box-sizing: border-box;
}
.note-form-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}
.note-form .menu-btn.save {
  background: #0078d7;
  color: #fff;
  padding: 6px 10px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  font-weight: 700;
}
.note-form .menu-btn.cancel {
  background: transparent;
  border: 1px solid #ddd;
  padding: 6px 8px;
  border-radius: 6px;
  cursor: pointer;
}

/* ========================================================================== */
/*                                Print Styles                                */
/* ========================================================================== */
@media print {
  @page {
    size: letter landscape;
    margin: 0.4in;
  }
  
  body {
    background: white;
    margin: 0;
    padding: 0;
  }
  
  .nav-bottom, .add-btn, .day-menu, .header-right, .submit-modal { display: none !important; }
  .assignment { cursor: default; }
  
  .header {
    margin: 0 0 8px 0;
    padding: 0;
  }
  
  #title {
    display: block;
    text-align: center;
    margin: 0 0 10px 0;
    font-size: 1.8em;
  }
  
  .weekday-row {
    font-size: 0.85em;
    max-width: 100%;
  }
  
  .weekday-row div {
    padding: 4px;
  }
  
  .calendar {
    max-width: 100%;
    grid-auto-rows: minmax(80px, auto);
    padding-bottom: 0;
    page-break-inside: avoid;
  }
  
  .day {
    min-height: 80px;
    padding: 4px;
    font-size: 0.85em;
    page-break-inside: avoid;
  }
  
  .day-number {
    font-size: 0.9em;
  }
  
  .shift-label {
    font-size: 0.65em;
  }
  
  .assignment {
    font-size: 0.8em;
    padding: 3px 5px;
    margin: 2px 0;
  }
  
  .assignment.note-card {
    background: white !important;
    border: 1px solid #ddd !important;
  }
  
  .holiday-label {
    font-size: 0.7em;
  }
  
  /* Force fit to one page */
  html, body {
    height: 100%;
    overflow: hidden;
  }
}

/* ========================================================================== */
/*                           Mobile Responsive                                */
/* ========================================================================== */
@media (max-width: 700px) {
  .header { flex-direction: column; align-items: stretch; margin: 8px auto 12px auto; gap: 8px; padding: 8px; }
  .header-left { width: 100%; }
  #title { font-size: 1.6em; }
  .header-right { justify-content: flex-start; }
  .nav-bottom { margin-top: 0; }
  .day-menu { min-width: 160px; }
  #note-input { min-width: 140px; }
}

/* ========================================================================== */
/*                           Loading Overlay + Spinner                        */
/* ========================================================================== */
#loading-overlay {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(255,255,255,0.6); display: none; align-items: center; justify-content: center; z-index: 9999;
}
.loading-box { background: #fff; padding: 18px 24px; border-radius: 10px; box-shadow: 0 6px 20px rgba(0,0,0,0.12); display: flex; flex-direction: column; align-items: center; gap: 12px; font-size: 15p[...]
.spinner { width: 36px; height: 36px; border: 5px solid #e0e0e0; border-top: 5px solid #0078d7; border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
