/* Light theme with custom brand colors */
:root {
  /* Color palette */
  --bg: #FFFFFF;
  --bg-alt: #F9FCFF;
  --bg-hover: rgba(31, 87, 154, 0.08);
  --border: rgba(31, 87, 154, 0.15);
  --border-strong: rgba(31, 87, 154, 0.25);
  --text: #1C1C1C;
  --text-dim: rgba(28, 28, 28, 0.6);
  --accent: #1F579A;
  --accent-hover: #2a6bb8;
  --accent-light: #3CD4FF;
  --brand-gradient: linear-gradient(135deg, rgba(31, 87, 154, 0.8), rgb(31, 87, 154));
  --slot-selected: rgba(31, 87, 154, 0.5);
  --slot-selected-border: rgba(31, 87, 154, 0.8);
  --weekend-bg: rgba(31, 87, 154, 0.1);
  --shadow: 0 2px 8px rgba(31, 87, 154, 0.12);
  
  /* Typography */
  --font-kit-base-font: 16;
  --font-kit-contrast: 2;
  --font-kit-header-font: 'Instrument Sans', sans-serif;
  --font-kit-header-font-weight: 600;
  --font-kit-header-line-height: 1.3;
  --font-kit-header-letter-spacing: -0.4px;
  --font-kit-header-transform: none;
  --font-kit-text-font: 'Instrument Sans', sans-serif;
  --font-kit-text-font-weight: 400;
  --font-kit-text-line-height: 1.5;
  --font-kit-text-letter-spacing: 0px;
  --font-kit-text-transform: none;
  --font-kit-text-font-weight-bold: 700;
  
  font-family: var(--font-kit-text-font);
  font-weight: var(--font-kit-text-font-weight);
  line-height: var(--font-kit-text-line-height);
}

/* Fix font-face formats & enforce consistent family usage */
@font-face {
  font-family: 'Instrument Sans';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('assets/fonts/InstrumentSans-Regular.ttf') format('truetype');
}
@font-face {
  font-family: 'Instrument Sans';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('assets/fonts/InstrumentSans-SemiBold.ttf') format('truetype');
}
@font-face {
  font-family: 'Instrument Sans';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('assets/fonts/InstrumentSans-Bold.ttf') format('truetype');
}

/* Global font enforcement */
html, body,
button, input, select, textarea,
h1, h2, h3, h4, h5, h6,
.week-progress, .month-title,
.confirm-btn, .slot, .day-header-cell,
.sidebar, .logout-btn {
  font-family: 'Instrument Sans', sans-serif;
  font-weight: 400;
  font-synthesis: none;
}

/* Headings use semi-bold (600) */
h1, h2, h3, h4, h5, h6,
.month-title {
  font-weight: 600;
}

/* Strong emphasis uses bold face (700) */
strong, b {
  font-weight: 700;
}

/* Slot labels already bold enough */
.slot-label {
  font-family: inherit;
  font-weight: 600;
}

/* Day header cells */
.day-header-cell {
  font-family: inherit;
  font-weight: 600;
}

/* Week progress normal text, bold inside strong already handled */
.week-progress {
  font-weight: 400;
}

/* Ensure inputs/buttons do not revert on some browsers */
button, input, select, textarea {
  font-size: inherit;
  line-height: inherit;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; background: var(--bg); color: var(--text); }
body { display: flex; flex-direction: column; }

/* Layout shell */
.app-shell { display:flex; min-height:100vh; width:100%; }
.sidebar { width:72px; background: var(--bg); border-right:1px solid var(--border); display:flex; flex-direction:column; align-items:center; padding:.75rem .5rem; gap:1rem; }
.logo-placeholder { width:48px; height:48px; border-radius:8px; object-fit:contain; }

/* Overrides for logout button */
.sidebar .logout-btn { 
  margin-top:auto; 
  background: transparent; 
  border:none; 
  color: var(--logout-color); 
  padding:0; 
  width:48px; 
  height:48px; 
  display:flex; 
  align-items:center; 
  justify-content:center; 
  cursor:pointer; 
  border-radius:10px; 
  transition: background .2s, color .2s, transform .2s; 
}
.sidebar .logout-btn .icon-logout { width:26px; height:26px; transform: rotate(180deg); }
.sidebar .logout-btn:hover, .sidebar .logout-btn:focus-visible { 
  background: var(--bg-hover); 
  color: var(--accent); 
  outline:none; 
}
.sidebar .logout-btn:active { transform: translateY(1px); }

.app-main { flex:1; display:flex; flex-direction:column; min-height:0; }

.top-bar { flex-direction:row; justify-content:flex-start; gap:1.5rem; align-items:center; }
.top-bar .spacer { flex:1; }

/* Calendar wrapper styling enhancements */
.calendar-wrapper { margin: 10px; /* border:1px solid var(--border); */ border-radius:10px; overflow:hidden; background: var(--bg); box-shadow: var(--shadow); }

.top-bar { display:flex; padding:1.2rem 1.2rem; background: var(--bg); border-bottom:1px solid var(--border); position:sticky; top:0; z-index:20; }
.month-nav { display:flex; align-items:center; gap:.6rem; }
.month-nav button { background: var(--bg); border:1px solid var(--border); color: var(--text); padding:.5rem .9rem; cursor:pointer; border-radius:999px; font-size:.95rem; transition: all 0.2s; }
.month-nav button:hover { background: var(--bg-hover); border-color: var(--accent); color: var(--accent); }
.month-nav button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background: var(--bg);
  color: var(--text-dim);
  border-color: var(--border);
}
.month-nav button:disabled:hover {
  background: var(--bg);
  color: var(--text-dim);
  border-color: var(--border);
}
.month-title { font-size:1.4rem; margin:0; font-family: var(--font-kit-header-font); font-weight: var(--font-kit-header-font-weight); letter-spacing: var(--font-kit-header-letter-spacing); line-height: var(--font-kit-header-line-height); }
/* round and minimal icon-only buttons */
.icon-btn { width:36px; height:36px; padding:0; display:inline-flex; align-items:center; justify-content:center; border: none !important; overflow: visible; }

/* Ensure icon-only nav buttons don't inherit month-nav padding */
.month-nav button.icon-btn { padding: 0 !important; }

/* Make the chevron SVGs fill more of the fixed-size button */
.month-nav button.icon-btn .icon-chevron { width: 24px !important; height: 24px !important; }
.week-progress {
  font-size:1rem;
  color: var(--text-dim);
  font-weight:500;
  display:flex;
  flex-direction:column;
  gap:6px;
  align-items: flex-end; /* align contents (text + bar) to the right */
}
.week-progress strong { color: var(--text); }
.week-progress .progress-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Progress bar under the progress text (no label) */
.progress-bar {
  width: 100%;
  max-width: 200px; /* limit to 200px */
  height: 8px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.06);
}
.progress-fill {
  height: 100%;
  width: 0%;
  background: var(--brand-gradient);
  transition: width .25s ease;
}

.calendar-wrapper { display:flex; flex:1; min-height:0; overflow:hidden; max-width:100%; }
body, .app-main { overflow:hidden; }
html { overflow-x:hidden; }
.time-column { width:64px; flex-shrink:0; border-right:1px solid var(--border); position:relative; background: var(--bg); overflow:hidden; padding-top: 58px; }
.time-column-inner { position:relative; height:calc(var(--hour-height) * 24); }
.calendar-right { display:flex; flex-direction:column; flex:1; min-width:0; }
.day-headers-bar { position:relative; background: var(--bg); border-bottom:1px solid var(--border); }
.day-headers-viewport { overflow:hidden; position:relative; }
.day-headers { display:grid; grid-auto-flow:column; grid-auto-columns:140px; will-change:transform; }
.day-header-cell { padding:.35rem .5rem; font-size:1rem; text-align:center; font-weight:600; /* border-right:1px solid var(--border); */ position:relative; }
.day-header-cell .dow { display:block; font-size:.8rem; color: var(--text-dim); font-weight:500; margin-top:2px; }
.time-column .hour-label { position:absolute; left:50%; transform:translate(-50%, -50%); font-size:.8rem; color: var(--text-dim); text-align:center; font-weight:500; }

.days-scroller { flex:1; overflow:auto; position:relative; scrollbar-gutter: stable both-edges; }
/* Overlay style scrollbars without affecting layout */
.days-scroller { scrollbar-width: thin; }
.days-scroller::-webkit-scrollbar { width:10px; height:10px; }
.days-scroller::-webkit-scrollbar-track { background: transparent; }
.days-scroller::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius:6px; border:2px solid transparent; background-clip:content-box; }
.days-scroller::-webkit-scrollbar-thumb:hover { background: var(--accent); border:2px solid transparent; background-clip:content-box; }
.days-grid { position:relative; min-height:100%; display:grid; grid-auto-flow:column; grid-auto-columns:140px; will-change:transform; max-width:100%; }
.day-column { position:relative; border-right:1px solid var(--border); }
.day-column.locked { 
  background: repeating-linear-gradient(-45deg, var(--weekend-bg) 0 8px, transparent 8px 16px);
}

/* Remove internal sticky header spacing now external */
.day-column { padding-top:0; }

/* Grid lines */
.grid-lines { position:absolute; inset:0; pointer-events:none; }
.grid-lines .hour-line { position:absolute; left:0; right:0; height:1px; background: var(--border); }
.grid-lines .half-hour-line { display: none; position:absolute; left:0; right:0; height:1px; background: var(--border); opacity:.4; }

/* Slots container */
.slots { position:absolute; inset:0; }
.slot { position:absolute; left:0px; right:8px; border-radius: 6px; cursor:pointer; background:var(--brand-gradient); border: 1px solid var(--slot-selected-border); box-shadow: var(--shadow); display:flex; align-items:center; justify-content:center; font-size:.8rem; line-height:1; user-select:none; color:#fff; }
.slot.dragging { opacity:.7; }
.slot.resizing { outline:1px dashed var(--accent-hover); }
.slot-label { padding:2px 4px; text-align:center; pointer-events:none; color:#fff; font-weight:600; }
.resize-handle { position:absolute; left:0; right:0; height:5px; cursor:ns-resize; }
.handle-top { top:-2px; }
.handle-bottom { bottom:-2px; }
.slot .delete-btn { position:absolute; top:2px; right:4px; width:14px; height:14px; font-size:12px; line-height:14px; background:rgba(31, 87, 154, 0.7); color:#fff; border-radius:3px; display:none; align-items:center; justify-content:center; cursor:pointer; font-weight:600; }
.slot:hover .delete-btn { display:flex; }
.slot .delete-btn:hover { background: #e53e3e; }

.selection-ghost { position:absolute; left:6px; right:6px; background:rgba(77,124,255,0.25); border:1px dashed var(--accent); border-radius:4px; pointer-events:none; }

.footer { padding:.75rem 1rem; border-top:1px solid var(--border); background: var(--bg); display:flex; justify-content:flex-end; }
button.danger { background: var(--danger); border:none; color:#fff; padding:.5rem .9rem; border-radius:6px; cursor:pointer; font-weight:500; }
button.danger:hover { filter:brightness(1.15); }

/* Scrollbar styling */
.days-scroller::-webkit-scrollbar { height:10px; width:10px; }
.days-scroller::-webkit-scrollbar-track { background: var(--bg); }
.days-scroller::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius:6px; }
.days-scroller::-webkit-scrollbar-thumb:hover { background: var(--accent); }

/* Responsive adjustments */
@media (max-width: 900px) {
  .days-grid, .day-headers { grid-auto-columns:120px; }
  .time-column { width:52px; }
}
@media (max-width: 600px) {
  .days-grid, .day-headers { grid-auto-columns:100px; }
  .month-title { font-size:1rem; }
}

/* Current day highlight */
.day-header-cell.today {
  background: var(--brand-gradient);
  color:#fff;
  border-radius: 6px;
  box-shadow: 0 2px 6px rgba(31,87,154,0.35);
}
.day-header-cell.today .dow {
  color: rgba(255,255,255,0.85);
}

.day-column.today {
  /* subtle column emphasis without overpowering events */
  /* background:
    linear-gradient(180deg, rgba(31,87,154,0.10), rgba(31,87,154,0.04)),
    var(--bg); */
  /* outline: 2px solid rgba(31,87,154,0.35); */
  outline: 2px solid rgba(60, 212, 255, 0.4);
  background: rgba(60, 212, 255, 0.05);
  border-radius: 4px;
  outline-offset:-2px;
}

.day-column.locked.today {
  /* keep highlight over locked pattern */
  background:
    linear-gradient(180deg, rgba(31,87,154,0.18), rgba(31,87,154,0.06)),
    repeating-linear-gradient(-45deg, var(--weekend-bg) 0 8px, transparent 8px 16px);
}

/* Sick day styling */
.day-column.sick-day {
  background: repeating-linear-gradient(-45deg, rgba(255, 200, 0, 0.15) 0 8px, transparent 8px 16px);
  pointer-events: none; /* Disable interaction in the grid */
}

/* Vacation day styling */
.day-column.vacation-day {
  background: repeating-linear-gradient(-45deg, rgba(34, 197, 94, 0.15) 0 8px, transparent 8px 16px);
  pointer-events: none; /* Disable interaction in the grid */
}

.day-header-cell {
  /* cursor: pointer; removed global pointer */
  position: relative; /* For absolute positioning of button */
  transition: background-color 0.2s;
}
.day-header-cell:hover {
  background-color: var(--bg-hover);
}

/* Toggle buttons container */
.toggle-btns-container {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  flex-direction: row;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.2s;
  z-index: 10;
}

.day-header-cell:hover .toggle-btns-container {
  opacity: 1;
}

.day-toggle-btn {
  width: 24px;
  height: 24px;
  background-color: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.sick-toggle-btn:hover {
  background-color: #fff;
  border-color: #f59e0b;
  color: #f59e0b;
  transform: scale(1.1);
}

.vacation-toggle-btn:hover {
  background-color: #fff;
  border-color: #22c55e;
  color: #22c55e;
  transform: scale(1.1);
}

.month-nav-arrows {
  display: inline-flex;
  align-items: center;
  gap: 0; /* no space between the two icon buttons */
}
