/* ============================================================
   Northfield Tire & Auto — Scheduling System
   Design tokens
   ------------------------------------------------------------
   Ink Navy   #14213D  -- header / nav / primary actions
   Steel      #4B5768  -- secondary text
   Cloud      #F5F6F8  -- page background
   Line       #DDE1E8  -- borders / dividers
   White      #FFFFFF  -- cards

   Schedule accent colors (one per tab, used consistently for
   that schedule's tab underline, appointment cards, and pills):
   Service      #2C5AA0  (blue)
   Alignment    #7B4B94  (plum)
   Tire         #2F8F5B  (green)
   Rotate       #C98A1E  (amber)
   Flat Repair  #B4432E  (brick)
   LOF          #1D8A8A  (teal)
   ============================================================ */

:root {
  --ink: #14213D;
  --steel: #4B5768;
  --steel-light: #7C879A;
  --cloud: #F5F6F8;
  --line: #DDE1E8;
  --white: #FFFFFF;
  --danger: #B4432E;
  --closed-bg: #ECEDEF;
  --blocked-bg: #FBEAEA;

  --c-service: #2C5AA0;
  --c-alignment: #7B4B94;
  --c-tire: #2F8F5B;
  --c-rotate: #C98A1E;
  --c-flat_repair: #B4432E;
  --c-lof: #1D8A8A;

  --radius: 8px;
  --shadow: 0 1px 3px rgba(20,33,61,0.10);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--cloud);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

button {
  font-family: inherit;
  font-size: inherit;
  cursor: pointer;
}

/* ---------------- Top bar ---------------- */

.topbar {
  background: var(--ink);
  color: var(--white);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--white);
  color: var(--ink);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.5px;
}

.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-name { font-weight: 600; font-size: 16px; }

.site-footer {
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--steel-light);
  padding: 18px 0 24px;
}

.topbar-links { display: flex; gap: 18px; }
.topbar-links a {
  text-decoration: none;
  font-size: 14px;
  color: #C6CEDE;
  padding: 6px 4px;
  border-bottom: 2px solid transparent;
}
.topbar-links a.active, .topbar-links a:hover {
  color: var(--white);
  border-bottom-color: var(--white);
}

/* ---------------- Page shell ---------------- */

.page {
  max-width: 1280px;
  margin: 0 auto;
  padding: 16px 20px 60px;
}

.page-title { font-size: 20px; margin: 6px 0 18px; }

/* ---------------- Schedule tabs ---------------- */

.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 14px;
  overflow-x: auto;
}

.tab {
  text-decoration: none;
  color: var(--steel);
  font-size: 14px;
  font-weight: 600;
  padding: 10px 16px 9px;
  border-bottom: 3px solid transparent;
  white-space: nowrap;
}

.tab:hover { color: var(--ink); }

.tab-service.active { color: var(--c-service); border-bottom-color: var(--c-service); }
.tab-alignment.active { color: var(--c-alignment); border-bottom-color: var(--c-alignment); }
.tab-tire.active { color: var(--c-tire); border-bottom-color: var(--c-tire); }
.tab-rotate.active { color: var(--c-rotate); border-bottom-color: var(--c-rotate); }
.tab-flat_repair.active { color: var(--c-flat_repair); border-bottom-color: var(--c-flat_repair); }
.tab-lof.active { color: var(--c-lof); border-bottom-color: var(--c-lof); }

/* ---------------- Toolbar ---------------- */

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
}

.toolbar-group { display: flex; align-items: center; gap: 8px; }

.view-toggle {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 3px;
}
.view-toggle button {
  border: none;
  background: transparent;
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 13px;
  color: var(--steel);
  font-weight: 600;
}
.view-toggle button.active {
  background: var(--ink);
  color: var(--white);
}

.nav-group { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); padding: 4px 6px; }
.nav-btn {
  border: none;
  background: transparent;
  font-size: 16px;
  padding: 5px 10px;
  border-radius: 6px;
  color: var(--ink);
}
.nav-btn:hover { background: var(--cloud); }
.today-btn { font-size: 13px; font-weight: 600; }
.date-label { font-weight: 600; font-size: 14px; margin-left: 8px; padding-right: 4px; }

.btn-primary {
  background: var(--ink);
  color: var(--white);
  border: none;
  padding: 9px 16px;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 14px;
}
.btn-primary:hover { background: #1E2E52; }

.btn-secondary {
  background: var(--white);
  color: var(--ink);
  border: 1px solid var(--line);
  padding: 9px 16px;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 14px;
}
.btn-secondary:hover { background: var(--cloud); }

.btn-danger {
  background: var(--white);
  color: var(--danger);
  border: 1px solid var(--danger);
  padding: 9px 16px;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 14px;
}
.btn-danger:hover { background: var(--blocked-bg); }

/* ---------------- Calendar root ---------------- */

.calendar-root {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

/* --- Day view --- */

.dropoffs-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: #FAFBFC;
}
.dropoffs-label { font-size: 12px; font-weight: 700; color: var(--steel); text-transform: uppercase; letter-spacing: 0.04em; margin-right: 4px; }
.dropoffs-empty { font-size: 13px; color: var(--steel-light); }

.day-grid { display: flex; flex-direction: column; }

.slot-row {
  display: flex;
  border-bottom: 1px solid var(--line);
  min-height: 56px;
}
.slot-row:last-child { border-bottom: none; }

.slot-time {
  width: 90px;
  flex-shrink: 0;
  padding: 8px 12px;
  font-size: 12.5px;
  color: var(--steel);
  border-right: 1px solid var(--line);
  background: #FAFBFC;
  display: flex;
  align-items: flex-start;
  padding-top: 14px;
}

.slot-cell {
  flex: 1;
  padding: 6px 10px;
  display: flex;
  align-items: stretch;
  position: relative;
}

.slot-cell.drag-over { background: #EEF2FA; }

.slot-empty-hint {
  flex: 1;
  display: flex;
  align-items: center;
  color: transparent;
  font-size: 13px;
  border-radius: 6px;
  cursor: pointer;
}
.slot-cell:hover .slot-empty-hint { color: var(--steel-light); background: #FAFBFC; }
.slot-empty-hint:hover { color: var(--steel); }

.closed-row .slot-time, .closed-row .slot-cell { background: var(--closed-bg); color: var(--steel-light); }

/* --- Appointment card --- */

.appt-card {
  width: 100%;
  border-left: 4px solid var(--c-service);
  background: #F3F6FC;
  border-radius: 6px;
  padding: 7px 10px;
  font-size: 13px;
  cursor: grab;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.appt-card:active { cursor: grabbing; }
.appt-card.dragging { opacity: 0.4; }

.appt-card.type-alignment { border-left-color: var(--c-alignment); background: #F6F1F9; }
.appt-card.type-tire { border-left-color: var(--c-tire); background: #F0F8F3; }
.appt-card.type-rotate { border-left-color: var(--c-rotate); background: #FBF4E7; }
.appt-card.type-flat_repair { border-left-color: var(--c-flat_repair); background: #FAEEEC; }
.appt-card.type-lof { border-left-color: var(--c-lof); background: #EBF6F6; }

.appt-name { font-weight: 700; }
.appt-meta { color: var(--steel); font-size: 12px; }
.appt-service { font-size: 12px; color: var(--ink); }

.dropoff-chip {
  border-left: 4px solid var(--c-service);
  background: #F3F6FC;
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 12.5px;
  cursor: grab;
  min-width: 150px;
}
.dropoff-chip.type-alignment { border-left-color: var(--c-alignment); background: #F6F1F9; }
.dropoff-chip.type-tire { border-left-color: var(--c-tire); background: #F0F8F3; }
.dropoff-chip.type-rotate { border-left-color: var(--c-rotate); background: #FBF4E7; }
.dropoff-chip.type-flat_repair { border-left-color: var(--c-flat_repair); background: #FAEEEC; }
.dropoff-chip.type-lof { border-left-color: var(--c-lof); background: #EBF6F6; }

/* --- Week view --- */

.week-grid { display: flex; }
.week-day-col {
  flex: 1;
  min-width: 0;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
}
.week-day-col:last-child { border-right: none; }
.week-day-header {
  padding: 10px 8px;
  text-align: center;
  border-bottom: 1px solid var(--line);
  background: #FAFBFC;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--steel);
  cursor: pointer;
}
.week-day-header.is-today { color: var(--ink); }
.week-day-header .wd-date { display: block; font-size: 15px; margin-top: 2px; color: var(--ink); }
.week-day-header.closed .wd-date { color: var(--steel-light); }

.week-dropoffs {
  padding: 6px;
  border-bottom: 1px solid var(--line);
  min-height: 20px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.week-slot {
  border-bottom: 1px solid #EEF0F3;
  min-height: 42px;
  padding: 3px 5px;
}
.week-slot.drag-over { background: #EEF2FA; }
.week-day-col.closed .week-slot { background: var(--closed-bg); }

.week-appt-card {
  border-left: 3px solid var(--c-service);
  background: #F3F6FC;
  border-radius: 5px;
  padding: 4px 6px;
  font-size: 11.5px;
  cursor: grab;
  line-height: 1.3;
}
.week-appt-card.type-alignment { border-left-color: var(--c-alignment); background: #F6F1F9; }
.week-appt-card.type-tire { border-left-color: var(--c-tire); background: #F0F8F3; }
.week-appt-card.type-rotate { border-left-color: var(--c-rotate); background: #FBF4E7; }
.week-appt-card.type-flat_repair { border-left-color: var(--c-flat_repair); background: #FAEEEC; }
.week-appt-card.type-lof { border-left-color: var(--c-lof); background: #EBF6F6; }

.week-time-col { width: 56px; flex-shrink: 0; }
.week-time-col .week-day-header { visibility: hidden; }
.week-time-label {
  font-size: 11px;
  color: var(--steel);
  padding: 3px 6px;
  border-bottom: 1px solid #EEF0F3;
  min-height: 42px;
}

/* --- Month view --- */

.month-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
}
.month-weekday-header {
  padding: 8px;
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--steel);
  border-bottom: 1px solid var(--line);
  background: #FAFBFC;
}
.month-cell {
  min-height: 96px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 6px 8px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.month-cell:hover { background: #FAFBFC; }
.month-cell.other-month { background: #FBFBFC; color: var(--steel-light); }
.month-cell.closed { background: var(--closed-bg); }
.month-cell.blocked { background: var(--blocked-bg); }
.month-cell.is-today .month-date { background: var(--ink); color: var(--white); border-radius: 50%; }

.month-date {
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
}

.month-counts { display: flex; flex-wrap: wrap; gap: 3px; }
.month-pill {
  font-size: 10.5px;
  padding: 1px 6px;
  border-radius: 10px;
  background: #F3F6FC;
  color: var(--c-service);
  font-weight: 600;
}
.month-label {
  font-size: 10px;
  color: var(--steel-light);
}

/* ---------------- Modal ---------------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20,33,61,0.45);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 16px;
  overflow-y: auto;
  z-index: 100;
}
.modal-backdrop.hidden { display: none; }

.modal {
  background: var(--white);
  border-radius: 12px;
  width: 100%;
  max-width: 560px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.25);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}
.modal-header h2 { margin: 0; font-size: 17px; }
.modal-close {
  border: none;
  background: transparent;
  font-size: 22px;
  line-height: 1;
  color: var(--steel);
}

.modal-body { padding: 18px 20px 20px; }

.field-row { margin-bottom: 14px; display: flex; gap: 14px; }
.field-row.two-col > .field { flex: 1; min-width: 0; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field.full { flex: 1; }
.field label { font-size: 12.5px; font-weight: 600; color: var(--steel); }

.field input[type="text"],
.field input[type="tel"],
.field input[type="date"],
.field select,
.field textarea {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 14px;
  font-family: inherit;
  color: var(--ink);
}
.field textarea { resize: vertical; }
.uc-field { text-transform: uppercase; }
.uc-field::placeholder { text-transform: none; }
.field input:focus, .field select:focus, .field textarea:focus {
  outline: 2px solid #2C5AA0;
  outline-offset: 1px;
}

.type-choice {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  margin-right: 20px;
}

.checkbox-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.checkbox-pill, .radio-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 6px 12px;
  background: var(--cloud);
}

.form-error {
  background: var(--blocked-bg);
  color: var(--danger);
  border: 1px solid #EAC3BC;
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 13px;
  margin-bottom: 12px;
}
.form-error.hidden { display: none; }

.modal-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
}
.modal-actions-right { display: flex; gap: 10px; }

.hidden { display: none !important; }

/* ---------------- Admin page ---------------- */

.admin-section {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}
.admin-section h2 { margin-top: 0; font-size: 16px; }
.hint { font-size: 13px; color: var(--steel); margin-top: -6px; }

.inline-form { display: flex; align-items: flex-end; gap: 14px; flex-wrap: wrap; margin: 14px 0 18px; }

.admin-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.admin-table th { text-align: left; padding: 8px 10px; border-bottom: 2px solid var(--line); color: var(--steel); font-size: 12px; text-transform: uppercase; letter-spacing: 0.03em; }
.admin-table td { padding: 8px 10px; border-bottom: 1px solid var(--line); }
.admin-table tr:hover td { background: #FAFBFC; }
.pill-holiday { background: #F3F6FC; color: var(--c-service); padding: 2px 8px; border-radius: 10px; font-size: 11.5px; font-weight: 600; }
.pill-custom { background: #FBF4E7; color: var(--c-rotate); padding: 2px 8px; border-radius: 10px; font-size: 11.5px; font-weight: 600; }
.link-btn { background: none; border: none; color: var(--danger); font-size: 13px; padding: 0; text-decoration: underline; }

.initial-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 6px 8px 6px 14px;
  font-size: 13px;
  font-weight: 700;
  background: var(--cloud);
}
.initial-chip button {
  background: none;
  border: none;
  color: var(--steel-light);
  font-size: 15px;
  line-height: 1;
  padding: 0 4px;
}
.initial-chip button:hover { color: var(--danger); }

.checkbox-pill-service input:checked ~ * , .checkbox-pill-service { }
.checkbox-pill-service { border-color: var(--c-service); }
.checkbox-pill-alignment { border-color: var(--c-alignment); }
.checkbox-pill-tire { border-color: var(--c-tire); }
.checkbox-pill-rotate { border-color: var(--c-rotate); }
.checkbox-pill-flat_repair { border-color: var(--c-flat_repair); }
.checkbox-pill-lof { border-color: var(--c-lof); }

/* ---------------- Responsive ---------------- */

@media (max-width: 720px) {
  .toolbar { flex-direction: column; align-items: stretch; }
  .toolbar-group { justify-content: center; }
  .slot-time { width: 64px; font-size: 11px; }
  .week-grid { overflow-x: auto; }
  .field-row.two-col { flex-direction: column; }
}
