/* Keeper — Calendar tab. Uses styles.css custom properties (with fallbacks). */

.cal-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  flex-wrap: wrap;
}
.cal-nav,
.cal-today,
.cal-view-toggle {
  min-height: 44px;
  min-width: 44px;
  border: 1px solid var(--line, #d8d3d8);
  border-radius: 10px;
  background: var(--panel, #fff);
  color: var(--ink, #221c22);
  font-size: 16px;
}
.cal-range {
  flex: 1;
  text-align: center;
  color: var(--ink-soft, #6d626d);
  font-size: 14px;
  min-width: 140px;
}

/* grid: corner + 7 day heads / time col + 7 day cols (day view: 1 col) */
.cal-grid {
  display: grid;
  grid-template-columns: 48px repeat(7, 1fr);
  grid-auto-rows: min-content 1fr;
  height: calc(100vh - 160px);
  min-height: 480px;
  margin: 0 8px 8px;
  border: 1px solid var(--line, #d8d3d8);
  border-radius: 12px;
  overflow: hidden;
  background: var(--panel, #fff);
}
.cal-grid.cal-day { grid-template-columns: 48px 1fr; }
.cal-corner { border-bottom: 1px solid var(--line, #d8d3d8); }
.cal-dayhead {
  padding: 8px 4px;
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft, #6d626d);
  border-bottom: 1px solid var(--line, #d8d3d8);
  border-left: 1px solid var(--line, #d8d3d8);
  cursor: pointer;
}
.cal-dayhead.is-today { color: var(--accent, #8e3b6e); }

.cal-timecol {
  display: flex;
  flex-direction: column;
}
.cal-hour-label {
  flex: 1;
  font-size: 11px;
  color: var(--ink-soft, #6d626d);
  text-align: right;
  padding: 2px 4px 0 0;
  border-top: 1px solid var(--line, #d8d3d8);
}
.cal-timecol .cal-hour-label:first-child { border-top: none; }

.cal-col {
  position: relative;
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--line, #d8d3d8);
}
.cal-hourline {
  flex: 1;
  border-top: 1px solid var(--line, #d8d3d8);
  pointer-events: none;
}
.cal-col .cal-hourline:first-child { border-top: none; }
.cal-col.is-closed { background: var(--bg, #f4f1f4); }
.cal-closed-note {
  position: absolute;
  top: 8px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 12px;
  color: var(--ink-soft, #6d626d);
}
.cal-offhours {
  position: absolute;
  left: 0;
  right: 0;
  background: color-mix(in srgb, var(--ink-soft, #6d626d) 8%, transparent);
  pointer-events: none;
}

/* blocked time (availability kind='blocked') — gray */
.cal-blocked {
  position: absolute;
  left: 2px;
  right: 2px;
  border-radius: 6px;
  background: var(--ink-soft, #6d626d);
  opacity: 0.35;
  overflow: hidden;
  cursor: pointer;
}
.cal-blocked-label {
  font-size: 11px;
  padding: 2px 4px;
  color: var(--panel, #fff);
}

/* appointment block: hatched container = processing gap; solid .cal-seg = busy */
.cal-appt {
  position: absolute;
  left: 2px;
  right: 2px;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  touch-action: none;
  --appt: var(--accent, #8e3b6e);
  background: repeating-linear-gradient(
    45deg,
    color-mix(in srgb, var(--appt) 22%, transparent) 0 4px,
    transparent 4px 8px
  );
  border: 1px solid color-mix(in srgb, var(--appt) 60%, transparent);
}
.cal-appt .cal-seg {
  position: absolute;
  left: 0;
  right: 0;
  background: color-mix(in srgb, var(--appt) 85%, var(--panel, #fff));
}
.cal-appt-label {
  position: relative;
  padding: 3px 6px;
  font-size: 12px;
  line-height: 1.25;
  color: var(--panel, #fff);
  display: flex;
  flex-direction: column;
  pointer-events: none;
}
.cal-appt.st-booked { --appt: var(--accent, #8e3b6e); }
.cal-appt.st-confirmed { --appt: var(--good, #2e7d4f); }
.cal-appt.st-arrived { --appt: var(--warn, #b07d1a); }
.cal-appt.st-done { --appt: var(--ink-soft, #6d626d); }
.cal-appt.st-no_show { --appt: var(--bad, #b3383d); }
.cal-appt.cal-dragging { opacity: 0.4; }
.cal-appt.cal-ghost {
  opacity: 0.75;
  pointer-events: none;
  outline: 2px dashed var(--accent, #8e3b6e);
}

/* bottom sheet */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 50;
}
.sheet {
  background: var(--panel, #fff);
  color: var(--ink, #221c22);
  border-radius: 16px 16px 0 0;
  padding: 16px;
  width: 100%;
  max-width: 480px;
  max-height: 85vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.sheet-title { font-size: 17px; font-weight: 700; }
.sheet-sub,
.sheet-note,
.sheet-result-sub { font-size: 13px; color: var(--ink-soft, #6d626d); }
.sheet-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.sheet-btn {
  min-height: 44px;
  border: 1px solid var(--line, #d8d3d8);
  border-radius: 10px;
  background: var(--panel, #fff);
  color: var(--ink, #221c22);
  font-size: 15px;
  text-align: center;
}
.sheet-btn.is-primary {
  background: var(--accent, #8e3b6e);
  border-color: var(--accent, #8e3b6e);
  color: #fff;
  font-weight: 600;
}
.sheet-btn.is-danger { color: var(--bad, #b3383d); border-color: var(--bad, #b3383d); }
.sheet-input {
  min-height: 44px;
  border: 1px solid var(--line, #d8d3d8);
  border-radius: 10px;
  background: var(--bg, #f4f1f4);
  color: var(--ink, #221c22);
  padding: 8px;
  font-size: 15px;
  width: 100%;
}
.sheet-row { display: flex; gap: 8px; }
.sheet-row .sheet-input { flex: 1; min-width: 0; }
.sheet-picked { font-weight: 600; }
.sheet-results { display: flex; flex-direction: column; gap: 4px; }
.sheet-result {
  min-height: 44px;
  text-align: left;
  border: 1px solid var(--line, #d8d3d8);
  border-radius: 10px;
  background: var(--bg, #f4f1f4);
  color: var(--ink, #221c22);
  padding: 6px 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.sheet-services {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 30vh;
  overflow-y: auto;
}
.sheet-service {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 4px;
}
.sheet-service .sheet-service-sub {
  margin-left: auto;
  font-size: 13px;
  color: var(--ink-soft, #6d626d);
}
.sheet-total { font-weight: 600; color: var(--accent, #8e3b6e); }
.is-hidden { display: none; }

@media (prefers-color-scheme: dark) {
  .cal-appt .cal-seg {
    background: color-mix(in srgb, var(--appt) 70%, var(--panel, #1d181d));
  }
}
