/* Machine Reservations - Compact calendar */
:root {
  --bg: #0f1419;
  --surface: #1a2332;
  --surface-hover: #243044;
  --border: #2d3a4d;
  --text: #e6edf3;
  --text-muted: #8b9cb3;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --booked: #22c55e;
  --booked-text: #052e16;
  --danger: #ef4444;
  --slot-height: 22px;
  --col-width: 72px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "DM Sans", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.4;
}

header {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

h1 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
}

.date-range {
  margin: 0.25rem 0 0;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.machine-tabs {
  display: flex;
  gap: 0.25rem;
  padding: 0.75rem 1.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.tab {
  flex: 1 1 0;
  min-width: 100px;
  padding: 0.5rem 1rem;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 0.8125rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.tab:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.day-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 0.75rem 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.day-arrow {
  padding: 0.5rem 1rem;
  background: var(--surface-hover);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 1rem;
  cursor: pointer;
}

.day-arrow:hover {
  background: var(--accent);
  border-color: var(--accent);
}

.day-label {
  font-weight: 600;
  min-width: 110px;
  text-align: center;
}

.mobile-only {
  display: none;
}

.calendar-wrapper {
  overflow: auto;
  padding: 1rem 1.5rem;
  max-height: calc(100vh - 180px);
  -webkit-overflow-scrolling: touch;
}

.calendar {
  display: grid;
  grid-template-columns: 40px repeat(13, 1fr);
  grid-auto-rows: var(--slot-height);
  grid-template-rows: var(--slot-height) repeat(48, var(--slot-height));
  gap: 1px;
  width: 100%;
  min-width: 0;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.corner {
  grid-column: 1;
  grid-row: 1;
  background: var(--surface);
}

.time-cell {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 0.5rem;
  background: var(--surface);
  font-size: 0.6875rem;
  color: var(--text-muted);
}

.day-header {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  font-size: clamp(0.5rem, 2vw, 0.75rem);
  font-weight: 600;
  text-align: center;
  white-space: nowrap;
  line-height: 1.2;
}

.slot {
  min-height: var(--slot-height);
  background: var(--surface);
  cursor: pointer;
  transition: background 0.1s;
  border: none;
  padding: 0;
  font: inherit;
  color: inherit;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.slot:hover {
  background: var(--surface-hover);
}

.slot.booked {
  background: var(--booked);
  color: var(--booked-text);
  cursor: pointer;
}

.slot.booked:hover {
  filter: brightness(1.1);
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.6);
  z-index: 1000;
  padding: 1rem;
}

.modal[hidden] {
  display: none;
}

.modal-content {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  max-width: 360px;
  width: 100%;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
}

.modal-content h2 {
  margin: 0 0 1rem;
  font-size: 1.125rem;
}

.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.25rem;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.form-group input {
  width: 100%;
  padding: 0.5rem 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 0.875rem;
}

.form-group input:focus {
  outline: none;
  border-color: var(--accent);
}

.form-group input[readonly] {
  opacity: 0.9;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1.25rem;
}

.btn {
  padding: 0.5rem 1rem;
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: background 0.15s;
}

.btn-primary {
  background: var(--accent);
  color: white;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-secondary {
  background: var(--surface-hover);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--border);
}

.btn-danger {
  background: var(--danger);
  color: white;
}

.btn-danger:hover {
  filter: brightness(1.1);
}

.codeword-error {
  color: var(--danger);
  font-size: 0.8125rem;
  margin: -0.5rem 0 0.5rem;
}

/* Mobile: smaller text so cells fit */
@media (max-width: 768px) {
  .calendar-wrapper {
    max-height: calc(100vh - 180px);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .day-header {
    font-size: clamp(0.45rem, 1.8vw, 0.6rem);
  }

  .time-cell {
    font-size: 0.55rem;
  }

  .slot {
    font-size: 0.65rem;
  }
}
