* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: #f5f5f7;
    color: #222;
}

.page {
    max-width: 1100px;
    margin: 0 auto;
    padding: 20px;
}

.page-header {
    margin-bottom: 20px;
}

.page-header h1 {
    margin: 0 0 8px;
    font-size: 24px;
}

.layout {
    display: grid;
    grid-template-columns: 1.1fr 1.4fr;
    gap: 20px;
}

.desks-panel,
.calendar-panel {
    background: #fff;
    border-radius: 16px;
    padding: 16px 20px 20px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.05);
}

.desks-panel h2,
.calendar-panel h2 {
    margin-top: 0;
    margin-bottom: 12px;
}

/* Легенда */
.legend {
    display: flex;
    gap: 16px;
    font-size: 14px;
    margin-bottom: 16px;
}

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

.legend-color {
    display: inline-block;
    width: 14px;
    height: 14px;
    border-radius: 4px;
    border: 1px solid rgba(0, 0, 0, 0.15);
}

.legend-free {
    background: rgba(76, 175, 80, 0.2);
}

.legend-booked {
    background: rgba(244, 67, 54, 0.3);
}

/* Схема столов */
.desk-grid {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.desk-row {
    display: flex;
    gap: 12px;
    justify-content: flex-start;
}

.desk {
    flex: 1 1 0;
    padding: 18px 10px;
    border-radius: 12px;
    border: 2px solid #d0d0d5;
    background: #f8f8fb;
    text-align: center;
    font-weight: 600;
    cursor: pointer;
    transition:
    transform 0.08s ease,
    box-shadow 0.08s ease,
    border-color 0.08s ease,
    background-color 0.08s ease;
}

.desk:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.08);
}

/* Свободен / занят сегодня */
.desk-free {
    background: rgba(76, 175, 80, 0.18);
    border-color: #4caf50;
}

.desk-booked {
    background: rgba(244, 67, 54, 0.28);
    border-color: #f44336;
}

/* Календарь */
.calendar-container {
    margin-top: 8px;
    border-radius: 14px;
    border: 1px solid #e0e0e5;
    padding: 12px;
    background: #fafafa;
}

.calendar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.calendar-title {
    font-weight: 600;
}

.nav-button {
    border-radius: 999px;
    border: 1px solid #d0d0d5;
    padding: 2px 8px;
    background: #fff;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    transition:
    background-color 0.08s ease,
    transform 0.08s ease,
    box-shadow 0.08s ease;
}

.nav-button:hover {
    background: #f0f0ff;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.08);
}

.calendar-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
    font-size: 12px;
    margin-bottom: 4px;
    color: #666;
}

.calendar-weekdays span {
    text-align: center;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
    min-height: 160px;
}

.calendar-day {
    border-radius: 8px;
    padding: 6px 0;
    font-size: 13px;
    text-align: center;
    cursor: pointer;
    border: 1px solid transparent;
    user-select: none;
    transition:
    background-color 0.08s ease,
    border-color 0.08s ease,
    transform 0.08s ease,
    box-shadow 0.08s ease;
}

.calendar-day-empty {
    pointer-events: none;
    background: transparent;
    border-color: transparent;
}

.calendar-day-free {
    background: rgba(76, 175, 80, 0.18);
    border-color: rgba(76, 175, 80, 0.4);
}

.calendar-day-free:hover {
    background: rgba(76, 175, 80, 0.28);
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(76, 175, 80, 0.25);
}

.calendar-day-booked {
    background: rgba(244, 67, 54, 0.26);
    border-color: rgba(244, 67, 54, 0.7);
    cursor: default;
    pointer-events: none; /* клик не даёт эффекта */
}

.calendar-day-today {
    box-shadow: 0 0 0 1px rgba(33, 150, 243, 0.7);
}

/* Подсказки */
.calendar-help {
    font-size: 13px;
    margin-top: 10px;
    color: #555;
}

#selected-desk-label {
    font-size: 14px;
    margin: 4px 0 8px;
}

/* Сообщения */
.message {
    margin-top: 10px;
    min-height: 18px;
    font-size: 13px;
}

.message-success {
    color: #2e7d32;
}

.message-error {
    color: #c62828;
}

.app-root--hidden {
    display: none;
}

.login-section {
    margin-bottom: 20px;
    padding: 16px 20px;
    border-radius: 16px;
    background: #ffffff;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.05);
}

.login-section p {
    margin-top: 0;
    margin-bottom: 12px;
}

/* День, забронированный текущим пользователем */
.calendar-day-booked-mine {
    background: rgba(156, 39, 176, 0.26);
    border-color: rgba(156, 39, 176, 0.8);
    cursor: pointer;
}

.calendar-day-booked-mine: hover {
    background: rgba(156, 39, 176, 0.35);
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(156, 39, 176, 0.4);
}

/* Мои Брони */
.my-bookings-panel {
  margin-top: 20px;
  background: #fff;
  border-radius: 16px;
  padding: 16px 20px 20px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.05);
}

.my-bookings-panel h2 {
  margin-top: 0;
  margin-bottom: 8px;
}

.my-bookings-note {
  margin-top: 0;
  margin-bottom: 12px;
  font-size: 13px;
  color: #666;
}

.my-bookings-empty {
  font-size: 14px;
  color: #777;
}

.my-bookings-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}

.my-booking-card {
  border-radius: 12px;
  border: 1px solid #e0e0e5;
  padding: 10px 12px;
  background: #fafafa;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
}

.my-booking-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.my-booking-desk {
  font-weight: 600;
}

.my-booking-date {
  font-variant-numeric: tabular-nums;
  color: #444;
}

.my-booking-meta {
  font-size: 12px;
  color: #777;
}

.my-booking-actions {
  margin-top: 6px;
  display: flex;
  justify-content: flex-end;
}

.my-booking-cancel-btn {
  border-radius: 999px;
  border: 1px solid #e57373;
  padding: 3px 10px;
  background: #ffebee;
  cursor: pointer;
  font-size: 12px;
  transition:
    background-color 0.08s ease,
    transform 0.08s ease,
    box-shadow 0.08s ease;
}

.my-booking-cancel-btn:hover {
  background: #ffcdd2;
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(244, 67, 54, 0.25);
}

/* === ГРИД БРОНИРОВАНИЯ =========================================== */

.schedule-panel {
  background: #fff;
  border-radius: 16px;
  padding: 16px 20px 20px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.05);
}

.schedule-note {
  margin-top: 0;
  margin-bottom: 10px;
  font-size: 13px;
  color: #666;
}

.schedule-wrapper {
  overflow-x: auto;
  padding-bottom: 8px;
  border-radius: 12px;
  border: 1px solid #e0e0e5;
  background: #fafafa;
}

.schedule-table {
  border-collapse: collapse;
  min-width: 700px;
  width: 100%;
  font-size: 13px;
}

.schedule-table th,
.schedule-table td {
  border-bottom: 1px solid #e0e0e5;
  padding: 6px 8px;
  text-align: center;
  white-space: nowrap;
}

.schedule-table th {
  font-weight: 600;
  background: #f3f3f7;
}

.schedule-table th:first-child,
.schedule-table td:first-child {
  position: sticky;
  left: 0;
  z-index: 2;
  background: #fdfdfd;
  text-align: left;
}

.schedule-table thead th:first-child {
  z-index: 3;
}

.schedule-desk-cell {
  font-weight: 600;
}

/* Кнопка-клетка */
.schedule-cell-btn {
  border: none;
  padding: 0;
  background: transparent;
  cursor: pointer;
}

/* Кружки */
.schedule-circle {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 999px;
  border: 2px solid transparent;
  box-sizing: border-box;
}

.schedule-circle-free {
  border-color: #bdbdbd;
  background: transparent;
}

.schedule-circle-free:hover {
  box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.35);
}

.schedule-circle-mine {
  background: #4caf50;
  border-color: #388e3c;
}

.schedule-circle-mine:hover {
  box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.5);
}

.schedule-circle-other {
  background: #f44336;
  border-color: #d32f2f;
}

/* Легенда под таблицей */
.schedule-legend {
  margin-top: 8px;
  font-size: 13px;
  color: #555;
}

.legend-circle {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 999px;
  margin-right: 4px;
  border: 2px solid transparent;
}

.legend-circle-free {
  border-color: #bdbdbd;
}

.legend-circle-mine {
  background: #4caf50;
  border-color: #388e3c;
}

.legend-circle-other {
  background: #f44336;
  border-color: #d32f2f;
}


/* Панель с гридом бронирования */
.booking-grid-panel {
  background: #fff;
  border-radius: 16px;
  padding: 16px 20px 16px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.05);
  margin-bottom: 20px;
}

.booking-grid-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 10px;
}

.booking-grid-note {
  margin: 4px 0 0;
  font-size: 13px;
  color: #666;
}

.booking-grid-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 13px;
}

.legend-dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 999px;
  border: 1px solid rgba(0, 0, 0, 0.15);
}

.legend-dot-mine {
  background: rgba(76, 175, 80, 0.9);
}

.legend-dot-other {
  background: rgba(244, 67, 54, 0.9);
}

/* Прокрутка по горизонтали */
.booking-grid-scroll {
  overflow-x: auto;
  border-radius: 12px;
  border: 1px solid #e0e0e5;
  background: #fafafa;
  padding: 6px;
}

/* Таблица-грид */
.booking-grid-table {
  border-collapse: separate;
  border-spacing: 0;
  min-width: 700px;
  font-size: 13px;
}

.booking-grid-table thead th {
  position: sticky;
  top: 0;
  z-index: 3;
  background: #f0f0f5;
  text-align: center;
  padding: 6px 8px;
  border-bottom: 1px solid #d0d0d5;
  border-right: 1px solid #e0e0e5;
  white-space: nowrap;
}

.booking-grid-table tbody td {
  padding: 6px 8px;
  text-align: center;
  border-bottom: 1px solid #f0f0f3;
  border-right: 1px solid #f0f0f3;
}

/* Липкий первый столбец со столами */
.booking-grid-table th:first-child,
.booking-grid-table td:first-child {
  position: sticky;
  left: 0;
  z-index: 4;
  background: #ffffff;
  text-align: left;
  font-weight: 600;
  min-width: 100px;     /* ← было условно 100px, теперь в 2 раза шире */
  white-space: nowrap;  /* ← текст НЕ переносится */
}

/* Последняя строка без нижней границы (чисто косметика) */
.booking-grid-table tbody tr:last-child td {
  border-bottom: none;
}

/* Еле заметная голубая подложка для каждой 2-й строки */
.booking-grid-table tbody tr:nth-child(even) {
  background: rgba(30, 144, 255, 0.03); /* light dodgerblue, ~6% opacity */
}

/* Название дня и даты в заголовке */
.booking-grid-day-name {
  font-size: 11px;
  color: #666;
}

.booking-grid-day-date {
  font-size: 12px;
  font-weight: 600;
}

/* кнопка-ячейка немного больше кружка */
.booking-cell-btn {
  position: relative;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  border: none;
  background: transparent;
  padding: 0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition:
    transform 0.08s ease,
    box-shadow 0.08s ease,
    background-color 0.08s ease;
  z-index: 3;
}

.booking-cell-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 3px 7px rgba(0, 0, 0, 0.15);
}

/* Пустая ячейка — лёгкий фон */
.booking-cell-empty .booking-cell-btn:hover {
  background: rgba(33, 150, 243, 0.08);
}

/* Сам кружок */
.booking-dot {
  width: 24px;
  height: 24px;
  border-radius: 999px;
}

/* Забронировано мной — зелёный кружок */
.booking-dot-mine {
  background: rgba(76, 175, 80, 0.7);
}

/* Забронировано другим — красный кружок */
.booking-dot-other {
  background: rgba(244, 67, 54, 0.7);
}

/* Запрещаем клик по чужой броне (хотя JS и так игнорирует) */
.booking-cell-other .booking-cell-btn {
  cursor: default;
  box-shadow: none;
}

.booking-cell-other .booking-cell-btn:hover {
  transform: none;
  background: transparent;
}

/* Ячейка грида — нужна относительная позиция для тултипа */
.booking-cell {
  position: relative;
}

.booking-tooltip {
  position: absolute;
  top: 50%;
  left: 100%;                    /* сразу справа от кружка */
  transform: translate(4px, -50%);
  background: #ffffff;
  border-radius: 999px;
  padding: 3px 8px;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.18);
  font-size: 11px;
  white-space: nowrap;
  opacity: 0;                    /* изначально невидим */
  pointer-events: auto;          /* ВСЕГДА ловит курсор */
  transition: opacity 0.12s ease, transform 0.12s ease;
  z-index: 5;
}

.booking-tooltip a {
  color: #1565c0;
  text-decoration: none;
}

.booking-tooltip a:hover {
  text-decoration: underline;
}

/* Ячейка — относительное позиционирование */
.booking-cell {
  position: relative;
}

/* Показываем тултип:
   - когда мышка над ячейкой с чужой бронью
   - ИЛИ над самим тултипом (даже если он “вылез” за пределы ячейки) */
.booking-cell-other:hover .booking-tooltip,
.booking-tooltip:hover {
  opacity: 1;
  transform: translate(-4px, -50%);
}

/* Шапка поддерживаен кнопку "Logout" */
.page-header-main {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.logout-button {
  display: none; /* по умолчанию скрыта, покажем из JS */
  border-radius: 999px;
  border: 1px solid #d32f2f;
  padding: 6px 14px;
  background: #ffebee;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
  transition:
    background-color 0.1s ease,
    transform 0.08s ease,
    box-shadow 0.08s ease;
}

.logout-button:hover {
  background: #ffcdd2;
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(211, 47, 47, 0.25);
}

/* Немного адаптивности */
@media (max-width: 900px) {
  .booking-grid-header {
    flex-direction: column;
    align-items: flex-start;
  }
}
