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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #f5f5f5;
  color: #333;
  line-height: 1.5;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 15px;
  border-bottom: 1px solid #ddd;
}

header h1 {
  font-size: 1.5rem;
  font-weight: 600;
}

#user-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

#user-name {
  font-weight: 500;
}

#sign-out-btn {
  padding: 6px 12px;
  background: #666;
  color: white;
  border: none;
  border-radius: 4px;
  font-size: 0.85rem;
  cursor: pointer;
}

#sign-out-btn:hover {
  background: #555;
}

/* Loading */
.loading {
  text-align: center;
  padding: 60px 20px;
  color: #666;
  font-size: 1.1rem;
}

/* Sign-in container */
#sign-in-container {
  max-width: 450px;
  margin: 40px auto;
}

/* Modal */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  justify-content: center;
  align-items: center;
  z-index: 100;
}

.modal.active {
  display: flex;
}

.modal-content {
  background: white;
  padding: 30px;
  border-radius: 8px;
  text-align: center;
  max-width: 400px;
  width: 90%;
}

.modal-content h2 {
  margin-bottom: 10px;
}

.modal-content p {
  color: #666;
  margin-bottom: 20px;
}

.modal-content input {
  width: 100%;
  padding: 12px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 1rem;
  margin-bottom: 15px;
}

.modal-content button {
  width: 100%;
  padding: 12px;
  background: #4a90d9;
  color: white;
  border: none;
  border-radius: 4px;
  font-size: 1rem;
  cursor: pointer;
}

.modal-content button:hover {
  background: #3a7bc8;
}

/* Main layout */
main {
  display: flex;
  gap: 30px;
}

/* Grid */
.grid-container {
  flex: 1;
  background: white;
  border-radius: 8px;
  padding: 20px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  overflow-x: auto;
}

.grid-header {
  display: grid;
  grid-template-columns: 60px repeat(7, 1fr);
  gap: 2px;
  margin-bottom: 2px;
}

.day-label {
  text-align: center;
  font-weight: 600;
  padding: 8px 4px;
  font-size: 0.9rem;
}

.time-label {
  font-size: 0.75rem;
  color: #666;
  text-align: right;
  padding-right: 8px;
}

.grid {
  display: grid;
  grid-template-columns: 60px repeat(7, 1fr);
  gap: 2px;
  user-select: none;
}

.grid-row {
  display: contents;
}

.grid-cell {
  height: 20px;
  background: #f0f0f0;
  border-radius: 2px;
  cursor: pointer;
  transition: background-color 0.1s;
  position: relative;
}

.grid-cell:hover {
  outline: 2px solid #4a90d9;
  outline-offset: -2px;
}

/* User's own availability */
.grid-cell.selected {
  background: #4a90d9;
}

/* Heat map colors for others' availability */
.grid-cell.heat-1 { background: #c8e6c9; }
.grid-cell.heat-2 { background: #a5d6a7; }
.grid-cell.heat-3 { background: #81c784; }
.grid-cell.heat-4 { background: #66bb6a; }
.grid-cell.heat-5 { background: #4caf50; }

/* Everyone available */
.grid-cell.all-available {
  background: #2e7d32;
}

/* Combined: user selected + others available */
.grid-cell.selected.heat-1,
.grid-cell.selected.heat-2,
.grid-cell.selected.heat-3,
.grid-cell.selected.heat-4,
.grid-cell.selected.heat-5 {
  background: linear-gradient(135deg, #4a90d9 50%, #4caf50 50%);
}

.grid-cell.selected.all-available {
  background: linear-gradient(135deg, #4a90d9 50%, #2e7d32 50%);
}

/* Sidebar */
.sidebar {
  width: 250px;
  flex-shrink: 0;
}

.sidebar h3 {
  font-size: 1rem;
  margin-bottom: 10px;
  color: #333;
}

.sidebar > div,
.sidebar > ul {
  background: white;
  border-radius: 8px;
  padding: 15px;
  margin-bottom: 20px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

#participants {
  list-style: none;
  background: white;
  border-radius: 8px;
  padding: 15px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

#participants li {
  padding: 5px 0;
  border-bottom: 1px solid #eee;
}

#participants li:last-child {
  border-bottom: none;
}

#participants li.current-user {
  font-weight: 600;
  color: #4a90d9;
}

/* Legend */
.legend-item {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.legend-color {
  width: 20px;
  height: 20px;
  border-radius: 3px;
}

.legend-color.your-availability { background: #4a90d9; }
.legend-color.all-available { background: #2e7d32; }
.legend-color.heat-high { background: #4caf50; }
.legend-color.heat-low { background: #c8e6c9; }

/* Best times */
#best-times {
  list-style: none;
}

#best-times li {
  padding: 8px 0;
  border-bottom: 1px solid #eee;
  font-size: 0.9rem;
}

#best-times li:last-child {
  border-bottom: none;
}

#best-times .time-slot {
  font-weight: 500;
}

#best-times .available-count {
  color: #666;
  font-size: 0.85rem;
}

/* Responsive */
@media (max-width: 900px) {
  main {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
  }
}
