/* ── Reset & podstawy ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: #f4f6f9;
  color: #1a1a2e;
  min-height: 100vh;
}

/* ── Navbar ── */
.navbar {
  background: #1a1a2e;
  color: #fff;
  padding: 0 2rem;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}
.nav-brand { font-weight: 700; font-size: 1.1rem; letter-spacing: .02em; color: inherit; text-decoration: none; }
.nav-links a {
  color: #c8d3e8;
  text-decoration: none;
  margin-left: 1.5rem;
  font-size: .95rem;
  transition: color .15s;
}
.nav-links a:hover { color: #fff; }
.nav-links a.nav-active {
  color: #fff;
  font-weight: 700;
  border-bottom: 2px solid #fff;
  padding-bottom: 2px;
}

main { padding: 1.5rem 2rem 3rem; max-width: 1400px; margin: 0 auto; }

/* ── Nagłówki sekcji ── */
h1 { font-size: 1.5rem; font-weight: 700; margin-bottom: 1rem; }
h2 { font-size: 1.15rem; font-weight: 600; margin-bottom: .75rem; }

/* ── Nawigacja tygodniowa ── */
.week-nav {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.week-nav .week-label {
  font-weight: 600;
  font-size: 1rem;
  color: #1a1a2e;
}
.btn {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .45rem 1rem;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  font-size: .9rem;
  font-weight: 500;
  text-decoration: none;
  transition: background .15s, color .15s;
}
.btn-outline {
  background: #fff;
  border: 1.5px solid #c5cfe0;
  color: #1a1a2e;
}
.btn-outline:hover { background: #e8edf5; }
.btn-primary { background: #1a1a2e; color: #fff; }
.btn-primary:hover { background: #2e2e4e; }
.btn-success { background: #16a34a; color: #fff; }
.btn-success:hover { background: #15803d; }
.btn-danger  { background: #dc2626; color: #fff; }
.btn-danger:hover  { background: #b91c1c; }
.btn-sm { padding: .3rem .65rem; font-size: .8rem; }

/* ── Siatka sal – wrapper ── */
.sale-wrapper {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}
@media (max-width: 900px) {
  .sale-wrapper { grid-template-columns: 1fr; }
  .sale-wrapper[data-sala-filter] .schedule-card { display: none; }
  .sale-wrapper[data-sala-filter="8"] .schedule-card[data-sala="8"],
  .sale-wrapper[data-sala-filter="7"] .schedule-card[data-sala="7"] { display: block; }
}

.sala-przelacz {
  margin: -.5rem 0 1rem;
  font-size: .9rem;
}
.sala-przelacz a {
  color: #1a1a2e;
  text-decoration: underline;
}

/* ── Siatka harmonogramu ── */
.schedule-card {
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 1px 4px rgba(0,0,0,.08);
  overflow: hidden;
}
.schedule-card-header {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .5rem 1rem;
  background: #1a1a2e;
}
.schedule-card h2 {
  color: #fff;
  font-size: 1rem;
  margin: 0;
}
.sala-miniatura {
  width: 56px;
  height: 56px;
  object-fit: cover;
  border-radius: 6px;
  flex-shrink: 0;
  cursor: pointer;
}

/* ── Powiększone zdjęcie sali po kliknięciu miniaturki ── */
.zdjecie-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  cursor: zoom-out;
  padding: 2rem;
  box-sizing: border-box;
}
.zdjecie-overlay img {
  max-width: 100%;
  max-height: 100%;
  border-radius: 10px;
  box-shadow: 0 8px 40px rgba(0,0,0,.4);
}

.schedule-grid {
  display: grid;
  overflow-x: auto;
}

.schedule-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .82rem;
  table-layout: fixed;
}
.schedule-table th {
  background: #f0f3f8;
  padding: .5rem .4rem;
  text-align: center;
  border: 1px solid #dde3ee;
  font-weight: 600;
  white-space: nowrap;
}
.schedule-table th.col-hour { width: 52px; }
.schedule-table td {
  border: 1px solid #e8ecf4;
  height: 48px;
  vertical-align: top;
  padding: 0;
  position: relative;
}
.schedule-table tr.end-row td {
  height: 0;
  border-top: 2px solid #c5cfe0;
  border-bottom: none;
  padding: 0;
}
.schedule-table tr.end-row td.hour-cell {
  text-align: right;
  padding-right: .4rem;
  vertical-align: top;
}
.schedule-table td.hour-cell {
  background: #f7f9fc;
  text-align: right;
  padding-right: .4rem;
  padding-top: 2px;
  color: #6b7280;
  font-size: .78rem;
  vertical-align: top;
  white-space: nowrap;
}

/* ── Blok rezerwacji ── */
.rez-block {
  position: absolute;
  left: 2px; right: 2px;
  border-radius: 4px;
  padding: 2px 5px;
  font-size: .75rem;
  line-height: 1.3;
  overflow: hidden;
  cursor: default;
  z-index: 2;
}
.rez-block.zatwierdzona {
  background: #dbeafe;
  border-left: 3px solid #2563eb;
  color: #1e3a8a;
}
.rez-block.oczekuje {
  background: #fef3c7;
  border-left: 3px solid #d97706;
  color: #78350f;
}
.rez-block .rez-name { font-weight: 600; }
.rez-block .rez-time { font-size: .7rem; opacity: .8; }
.rez-block .rez-detail { font-size: .7rem; opacity: .75; font-style: italic; }

/* ── Podświetlenie świeżo dodanej rezerwacji ── */
.rez-block-nowa { animation: pulsujNowa 2s ease; }
@keyframes pulsujNowa {
  0%   { box-shadow: 0 0 0 3px rgba(217,119,6,.55); }
  100% { box-shadow: 0 0 0 3px rgba(217,119,6,0); }
}

/* ── Panel szkoły: rozróżnienie własnych i cudzych terminów ── */
.rez-block-cudza { opacity: .45; }
.rez-block-wlasna:hover { box-shadow: 0 0 0 2px rgba(37,99,235,.5); }

/* ── Dzień bieżący ── */
.today-col { background: #f0f7ff !important; }

/* ── Formularz ── */
.form-card {
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 1px 4px rgba(0,0,0,.08);
  padding: 2rem;
  max-width: 540px;
}
.form-group { margin-bottom: 1.1rem; }
.form-group label {
  display: block;
  font-weight: 600;
  font-size: .9rem;
  margin-bottom: .35rem;
  color: #374151;
}
.form-group input:not([type="checkbox"]),
.form-group select,
.form-group textarea {
  width: 100%;
  padding: .55rem .75rem;
  border: 1.5px solid #d1d5db;
  border-radius: 6px;
  font-size: .95rem;
  font-family: inherit;
  transition: border-color .15s;
}
.form-group input[type="date"],
.form-group input[type="time"] {
  -webkit-appearance: none;
  appearance: none;
  height: 2.6rem;
  padding-top: 0;
  padding-bottom: 0;
}
.form-group input[type="date"]::-webkit-datetime-edit,
.form-group input[type="time"]::-webkit-datetime-edit {
  padding: 0;
}
.form-group input[type="date"]::-webkit-datetime-edit-fields-wrapper,
.form-group input[type="time"]::-webkit-datetime-edit-fields-wrapper {
  display: flex;
  align-items: center;
  height: 100%;
}
.form-group input[type="checkbox"] {
  width: auto;
  vertical-align: middle;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: #2563eb;
}
.form-row { display: flex; gap: 1rem; }
.form-row .form-group { flex: 1; }
.form-hint { font-size: .8rem; color: #6b7280; margin-top: .25rem; }

.alert {
  padding: .75rem 1rem;
  border-radius: 6px;
  margin-bottom: 1rem;
  font-size: .9rem;
}
.alert-danger  { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.alert-success { background: #dcfce7; color: #166534; border: 1px solid #86efac; }
.alert-info    { background: #dbeafe; color: #1e3a8a; border: 1px solid #93c5fd; }

/* ── Tabela oczekujących ── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .88rem;
  margin-bottom: 1.5rem;
}
.data-table th {
  background: #f0f3f8;
  padding: .5rem .75rem;
  text-align: left;
  border-bottom: 2px solid #dde3ee;
  font-weight: 600;
}
.data-table td {
  padding: .5rem .75rem;
  border-bottom: 1px solid #eef0f5;
  vertical-align: middle;
}
.data-table tr:hover td { background: #f7f9fc; }

.badge {
  display: inline-block;
  padding: .2rem .55rem;
  border-radius: 99px;
  font-size: .75rem;
  font-weight: 600;
}
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-success { background: #dcfce7; color: #166534; }
.badge-danger  { background: #fee2e2; color: #991b1b; }

/* ── Klikalne komórki siatki ── */
/* touch-action: none i user-select: none są stałe (nie tylko w trakcie
   przeciągania) — inaczej iOS Safari zdąży pokazać własne menu zaznaczania
   tekstu ("Kopiuj" / "Znajdź zaznaczenie") zanim JS w ogóle zareaguje. */
.clickable-cell {
  cursor: pointer;
  transition: background .1s;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}
.clickable-cell:hover { background: #e8f0fe !important; }
.clickable-cell.cell-selecting { background: #bfdbfe !important; }
/* Termin zebrany w trybie Ctrl/Cmd (wielokrotne zaznaczanie), czeka na otwarcie okienka */
.clickable-cell.cell-multi-selected { background: #bbf7d0 !important; }
/* Termin, który już minął — nie da się go zarezerwować, tylko podgląd */
.clickable-cell.cell-minal { cursor: not-allowed; }
.clickable-cell.cell-minal:hover { background: transparent !important; }

kbd {
  display: inline-block;
  padding: .1rem .4rem;
  border: 1px solid #d1d5db;
  border-bottom-width: 2px;
  border-radius: 4px;
  background: #f3f4f6;
  font-family: inherit;
  font-size: .85em;
}

/* ── Blokada zaznaczania tekstu podczas przeciągania ── */
body.no-select { user-select: none; -webkit-user-select: none; }

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

.modal-box {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 8px 40px rgba(0,0,0,.25);
  width: 100%;
  max-width: 540px;
  max-height: 90vh;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 1.5rem;
  box-sizing: border-box;
  animation: modalIn .18s ease;
}
@keyframes modalIn {
  from { opacity: 0; transform: scale(.96) translateY(-8px); }
  to   { opacity: 1; transform: scale(1)  translateY(0); }
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 1.1rem;
}
.modal-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: #1a1a2e;
}
.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  line-height: 1;
  color: #9ca3af;
  cursor: pointer;
  padding: 0 .25rem;
  transition: color .15s;
}
.modal-close:hover { color: #1a1a2e; }

.hidden { display: none !important; }

/* ── Druk ── */
@media print {
  body { background: #fff; font-size: 10pt; }
  .navbar, .week-nav, .no-print { display: none !important; }
  main { padding: 0; max-width: 100%; }
  .sale-wrapper { grid-template-columns: 1fr; }
  .schedule-card { box-shadow: none; border: 1px solid #999; page-break-inside: avoid; margin-bottom: 1cm; }
  .schedule-table th, .schedule-table td { border: 1px solid #bbb; }
  .schedule-table { font-size: 8.5pt; }
  h1 { font-size: 13pt; }
  h2 { font-size: 11pt; }
  @page { size: A4 landscape; margin: 1cm; }
}
