* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  overflow-x: hidden;
  max-width: 100%;
}

body {
  font-family: Arial, sans-serif;
  background: #f5f5f5;
  min-height: 100vh;
  display: flex;
  /* Column, so the preview banner and "View as" picker sit above the card. */
  flex-direction: column;
  align-items: center;
  padding: 24px 12px;
}

.card {
  background: white;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  width: 100%;
  max-width: 640px;
  overflow: hidden;
}

/* Team calendar tab: room for a whole month (31 day columns + names)
   without sideways scrolling on a laptop. Toggled by switchTab (app.js). */
.card.wide {
  max-width: 1100px;
}

.card-header {
  background: #4a86e8;
  padding: 24px;
}

.card-header h1 {
  color: white;
  font-size: 22px;
  margin: 0;
}

.card-header p {
  color: rgba(255,255,255,0.85);
  margin-top: 4px;
  font-size: 14px;
}

.card-body {
  padding: 20px;
}

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

label {
  display: block;
  font-weight: bold;
  font-size: 14px;
  margin-bottom: 6px;
  color: #333;
}

input[type="text"],
input[type="date"],
input[type="time"],
select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 14px;
  color: #333;
  transition: border-color 0.2s;
  background: white;
}

input:focus, select:focus {
  outline: none;
  border-color: #4a86e8;
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.toggle {
  position: relative;
  width: 48px;
  height: 26px;
  flex-shrink: 0;
}

.toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  inset: 0;
  background: #ccc;
  border-radius: 26px;
  cursor: pointer;
  transition: 0.3s;
}

.slider:before {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  left: 3px;
  bottom: 3px;
  background: white;
  border-radius: 50%;
  transition: 0.3s;
}

.toggle input:checked + .slider {
  background: #4a86e8;
}

.toggle input:checked + .slider:before {
  transform: translateX(22px);
}

.toggle-label {
  font-size: 14px;
  color: #333;
}

.date-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.time-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 12px;
}

.time-row.hidden { display: none; }

.half-day-row {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.half-day-row.hidden { display: none; }

.half-day-btn {
  flex: 1;
  min-width: 130px;
  padding: 8px 10px;
  border-radius: 4px;
  border: 1px solid #4a86e8;
  background: white;
  color: #4a86e8;
  font-size: 13px;
  font-weight: bold;
  cursor: pointer;
}

.half-day-btn:hover { background: #f0f4ff; }

.user-search {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #ddd;
  border-radius: 4px 4px 0 0;
  font-size: 14px;
  border-bottom: none;
  background: white;
}

.user-search:focus {
  outline: none;
  border-color: #4a86e8;
}

.user-list {
  border: 1px solid #ddd;
  border-radius: 0 0 4px 4px;
  max-height: 200px;
  overflow-y: auto;
  background: white;
}

.user-option {
  padding: 8px 12px;
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background 0.15s;
}

.user-option:hover { background: #f0f4ff; }

.user-option.selected {
  background: #e8f0fe;
  font-weight: bold;
}

.user-option input[type="checkbox"] {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  cursor: pointer;
}

.selected-users {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.user-chip {
  background: #e8f0fe;
  color: #1a56db;
  border-radius: 16px;
  padding: 4px 10px;
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.user-chip button {
  background: none;
  border: none;
  color: #1a56db;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 0;
}

.card-footer {
  padding: 16px 20px;
  border-top: 1px solid #e0e0e0;
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}

.btn {
  padding: 10px 24px;
  border-radius: 4px;
  font-size: 14px;
  font-weight: bold;
  cursor: pointer;
  border: none;
  transition: opacity 0.2s;
}

.btn:hover { opacity: 0.85; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary { background: #4a86e8; color: white; }

.btn-secondary {
  background: #f5f5f5;
  color: #333;
  border: 1px solid #ddd;
}

.status {
  display: none;
  padding: 12px 16px;
  border-radius: 4px;
  font-size: 14px;
  margin-bottom: 16px;
}

.status.success { background: #d9ead3; color: #2d6a2d; display: block; }
.status.error { background: #fce5cd; color: #7a3000; display: block; }
.status.info { background: #e8f0fe; color: #1a56db; display: block; }

.loading {
  text-align: center;
  padding: 12px;
  color: #757575;
  font-size: 14px;
}

.tabs {
  display: flex;
  border-bottom: 1px solid #e0e0e0;
}

.tab-btn {
  flex: 1;
  padding: 14px 8px;
  background: none;
  border: none;
  font-size: 14px;
  font-weight: bold;
  color: #757575;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  transition: color 0.2s, border-color 0.2s;
}

.tab-btn.active {
  color: #4a86e8;
  border-bottom-color: #4a86e8;
}

.tab-btn:hover:not(.active) { color: #333; }

.hidden { display: none; }

.weekday-pill {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid #ddd;
  background: white;
  color: #333;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.weekday-pill.active {
  background: #4a86e8;
  color: white;
  border-color: #4a86e8;
}

#previewPicker {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  max-width: 640px;
  margin-bottom: 8px;
  font-size: 13px;
  color: #555;
}
#previewPicker.hidden { display: none; }
#previewBanner:not(.hidden) { display: block; margin-bottom: 8px; border-radius: 4px; }
#previewPicker select {
  flex: 1;
  padding: 6px 8px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 13px;
}

#previewBanner {
  display: none;
  background: #fef3c7;
  color: #78350f;
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  border-bottom: 2px solid #f59e0b;
  width: 100%;
  max-width: 640px;
}

/* OOO_MODE='sandbox' only (org.ts) — "TEST MODE" banner, deliberately a
   different colour from #previewBanner above so the two are easy to tell
   apart when both show at once (a tester previewing as someone else). */
#sandboxBanner {
  display: block;
  background: #4a86e8;
  color: white;
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 700;
  text-align: center;
  border-bottom: 2px solid #2f5fbd;
  width: 100%;
  max-width: 640px;
}
#sandboxBanner.hidden { display: none; }

#sandboxForbiddenCard .card-body { text-align: center; padding: 32px 24px; }
#sandboxForbiddenMessage { color: #555; font-size: 15px; line-height: 1.5; }

/* Sign-in gate */
#signinGate {
  background: white;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  width: 100%;
  max-width: 400px;
  padding: 32px 24px;
  text-align: center;
}

#signinGate h1 { font-size: 20px; margin-bottom: 8px; color: #333; }
#signinGate p { font-size: 14px; color: #757575; margin-bottom: 20px; }
#signinGate .g_id_signin_wrap { display: flex; justify-content: center; }

@media (max-width: 480px) {
  .card-footer { justify-content: stretch; }
  .card-footer .btn { flex: 1; }
}

/* ============================================================
   TEAM CALENDAR — Outlook-style "who's off when" grid (teamCalendar.js).
   Narrow day columns, sticky name column + header row, horizontal scroll
   on a phone. Cell colors deliberately match availabilityEmailHtml.ts's
   COLORS so the approval-email grid and this page look like one system.
   ============================================================ */
.team-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.team-picker {
  padding: 8px 10px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 13px;
  color: #333;
  background: white;
}

.team-view-toggle {
  display: flex;
  border: 1px solid #ddd;
  border-radius: 4px;
  overflow: hidden;
}

.view-btn {
  padding: 7px 14px;
  border: none;
  background: white;
  color: #333;
  font-size: 13px;
  cursor: pointer;
}

.view-btn + .view-btn { border-left: 1px solid #ddd; }
.view-btn.active { background: #4a86e8; color: white; }

.team-nav {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}

.nav-btn {
  padding: 7px 12px;
  border: 1px solid #ddd;
  border-radius: 4px;
  background: white;
  color: #333;
  font-size: 13px;
  cursor: pointer;
}

.nav-btn:hover { background: #f0f4ff; }
.nav-btn-today { font-weight: bold; }

.team-period-label {
  font-size: 14px;
  font-weight: bold;
  color: #333;
  margin-bottom: 10px;
}

.team-grid-scroll {
  overflow-x: auto;
  overflow-y: visible;
  border: 1px solid #e0e0e0;
  border-radius: 4px;
  max-width: 100%;
}

table.team-grid {
  border-collapse: collapse;
  font-size: 11px;
}

.team-grid th,
.team-grid td {
  border: 1px solid #eee;
  padding: 0;
  text-align: center;
}

.team-grid .name-col {
  position: sticky;
  left: 0;
  z-index: 2;
  background: white;
  text-align: left;
  padding: 6px 8px;
  font-size: 12px;
  color: #333;
  white-space: nowrap;
  max-width: 130px;
  overflow: hidden;
  text-overflow: ellipsis;
  box-shadow: 1px 0 0 #e0e0e0;
}

.team-grid thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #fafafa;
}

.team-grid thead th.name-col { z-index: 3; }

.day-col {
  width: 30px;
  min-width: 30px;
  padding: 4px 0;
  font-size: 10px;
  color: #757575;
}

.team-grid.month-view .day-col,
.team-grid.month-view .day-cell {
  width: 20px;
  min-width: 20px;
}

.day-col-weekday { font-size: 9px; color: #9aa0a6; }
.day-col-num { font-weight: bold; color: #333; }

.day-col.nonworking-col { background: #f5f5f5; }
.day-col.today-col { background: #e8f0fe; }

.day-cell {
  height: 22px;
  cursor: default;
}

.day-cell.today-col { box-shadow: inset 0 0 0 2px #4a86e8; }

.state-none { background: #ffffff; }
.state-off { background: #ea4335; }
.state-offPartial { background: #f3b6b0; }
.state-pending { background: #f9ab00; }
.state-pendingPartial { background: #fbd88a; }
.state-nonWorking { background: #e8eaed; }

.summary-label {
  font-weight: bold;
  font-size: 11px;
  background: #fafafa;
}

.summary-cell {
  font-size: 9px;
  color: #555;
  background: #fafafa;
}

.summary-cell.summary-heavy {
  color: #b3261e;
  font-weight: bold;
}

.team-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 12px;
  font-size: 12px;
  color: #555;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend-swatch {
  display: inline-block;
  width: 12px;
  height: 12px;
  border: 1px solid rgba(0,0,0,0.1);
  border-radius: 2px;
}

@media (max-width: 480px) {
  .team-nav { margin-left: 0; }
  .team-controls { justify-content: stretch; }
}
