*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #ffffff;
  color: #111827;
}

body {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

.app-root {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100vh;
  background: #ffffff;
  overflow: hidden;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1.5rem;
  border-bottom: 1px solid #e5e7eb;
  background: #ffffff;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand {
  display: flex;
  flex-direction: column;
}

.brand-main {
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: 0.9rem;
  color: #1d4ed8;
}

.brand-sub {
  font-size: 0.75rem;
  color: #6b7280;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.user-section {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.85rem;
}

.pill {
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border: 1px solid #d1d5db;
  color: #6b7280;
  background: #f9fafb;
}

.pill-admin {
  border-color: #2563eb;
  color: #1d4ed8;
  background: #eff6ff;
}

.btn {
  border-radius: 999px;
  padding: 0.35rem 0.9rem;
  border: 1px solid #d1d5db;
  background: #ffffff;
  color: #111827;
  cursor: pointer;
  font-size: 0.8rem;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.05s ease;
}

.btn:hover {
  background: #e5f0ff;
  border-color: #2563eb;
  transform: translateY(-0.5px);
}

.btn-primary {
  border-radius: 0.75rem;
  padding: 0.45rem 1rem;
  border: none;
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: white;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  box-shadow: 0 10px 30px rgba(37, 99, 235, 0.35);
  transition: transform 0.08s ease, box-shadow 0.08s ease, filter 0.08s ease;
}

.btn-primary:hover {
  filter: brightness(1.05);
  transform: translateY(-1px);
  box-shadow: 0 18px 45px rgba(37, 99, 235, 0.5);
}

.btn-secondary {
  border-radius: 0.75rem;
  padding: 0.45rem 1rem;
  border: 1px solid #d1d5db;
  background: #f9fafb;
  color: #111827;
  cursor: pointer;
  font-size: 0.85rem;
  transition: background 0.1s ease, border-color 0.1s ease, transform 0.05s ease;
}

.btn-secondary:hover {
  background: #f3f4f6;
  border-color: #9ca3af;
  transform: translateY(-1px);
}

.btn-danger {
  border-radius: 0.75rem;
  padding: 0.45rem 1rem;
  border: 1px solid #ef4444;
  background: #ffffff;
  color: #dc2626;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  transition: background 0.1s ease, border-color 0.1s ease, transform 0.05s ease;
}

.btn-danger:hover {
  background: #fef2f2;
  border-color: #dc2626;
  transform: translateY(-1px);
}

.app-main {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 0;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.app-main.has-admin-panel {
  grid-template-columns: 260px minmax(0, 1fr) 300px;
}

@media (max-width: 1024px) {
  .app-main {
    grid-template-columns: 240px minmax(0, 1fr);
  }
  .app-main.has-admin-panel {
    grid-template-columns: 240px minmax(0, 1fr) 280px;
  }
  .admin-panel {
    display: none;
  }
}

@media (max-width: 768px) {
  .app-main {
    grid-template-columns: minmax(0, 1fr);
  }
  .sidebar {
    display: none;
  }
}

.sidebar,
.admin-panel {
  border-right: 1px solid #e5e7eb;
  border-left: 1px solid #e5e7eb;
  background: #f9fafb;
  padding: 0.9rem 0.9rem 0.9rem;
  overflow-y: auto;
  height: 100%;
}

.admin-panel {
  border-right: none;
  border-left: 1px solid #e5e7eb;
  display: none; /* Hidden by default, shown via JS when admin is logged in */
}

.sidebar-section {
  margin-bottom: 1.2rem;
}

.section-title {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: #6b7280;
  margin: 0 0 0.6rem;
}

.space-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.space-separator {
  margin: 0.5rem 0;
  padding: 0;
  height: 1px;
  display: flex;
  align-items: center;
}

.space-separator-line {
  width: 100%;
  height: 1px;
  background: #e5e7eb;
}

.space-item {
  border-radius: 0.75rem;
  padding: 0.45rem 0.5rem;
  cursor: pointer;
  border: 1px solid transparent;
  background: #ffffff;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  transition: border-color 0.12s ease, background 0.12s ease, transform 0.08s ease, box-shadow 0.12s ease;
}

.space-item:hover {
  border-color: #bfdbfe;
  background: #eff6ff;
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(15, 23, 42, 0.08);
}

.space-item.active {
  border-color: #2563eb;
  box-shadow: 0 0 0 1px #2563eb;
}

.space-name {
  font-size: 0.85rem;
  color: #111827;
}

.space-meta {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.badge {
  font-size: 0.65rem;
  border-radius: 999px;
  padding: 0.05rem 0.4rem;
  border: 1px solid #d1d5db;
  color: #6b7280;
}

.badge-approval {
  border-color: #f97316;
  color: #9a3412;
  background: #fff7ed;
}

.badge-music {
  border-color: #2563eb;
  color: #1d4ed8;
  background: #eff6ff;
}

.badge-study {
  border-color: #2563eb;
  color: #1d4ed8;
  background: #eff6ff;
}

.rules ul {
  margin: 0;
  padding-left: 1rem;
  font-size: 0.8rem;
  color: #6b7280;
  line-height: 1.5;
}

.calendar-area {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: #ffffff;
  height: 100%;
  overflow: hidden;
  flex: 1;
  min-height: 0;
  max-height: 100%;
}

.calendar-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.7rem 1.1rem;
  border-bottom: 1px solid #e5e7eb;
}

.view-toggle {
  display: inline-flex;
  background: #e5f0ff;
  border-radius: 999px;
  padding: 0.18rem;
  border: 1px solid #bfdbfe;
  box-shadow: none;
}

.view-btn {
  border-radius: 999px;
  border: none;
  background: transparent;
  color: #6b7280;
  font-size: 0.75rem;
  padding: 0.25rem 0.8rem;
  cursor: pointer;
  transition: background 0.1s ease, color 0.1s ease, box-shadow 0.1s ease, transform 0.05s ease;
}

.view-btn.active {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: white;
  box-shadow: 0 8px 16px rgba(37, 99, 235, 0.35);
}

.view-btn:not(.active):hover {
  background: #e0ecff;
  color: #111827;
}

.date-controls {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.date-label {
  font-size: 0.85rem;
  color: #111827;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  background: #eff6ff;
  border: 1px solid #d1d5db;
}

.nav-btn {
  border-radius: 999px;
  border: 1px solid #d1d5db;
  background: #ffffff;
  color: #6b7280;
  width: 1.8rem;
  height: 1.8rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.85rem;
  transition: background 0.1s ease, border-color 0.1s ease, color 0.1s ease, transform 0.05s ease;
}

.nav-btn:hover {
  background: #e0ecff;
  border-color: #2563eb;
  color: #111827;
  transform: translateY(-1px);
}

.calendar-container {
  flex: 1;
  padding: 0.8rem 1.1rem 1.1rem;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  min-height: 0;
  height: 100%;
  max-height: 100%;
}

.calendar-scroll {
  flex: 1 1 0;
  border-radius: 1rem;
  border: 1px solid #e5e7eb;
  background: #ffffff;
  box-shadow: none;
  overflow: auto;
  padding: 0.4rem 0.4rem 0.6rem;
  min-height: 0;
}

.day-grid {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  column-gap: 0.5rem;
  position: relative;
  min-height: 400px;
  height: 100%;
  flex: 1;
}

.time-column {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.time-label {
  height: 40px;
  font-size: 0.65rem;
  color: #6b7280;
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  padding-top: 0.1rem;
}

.slots-column {
  position: relative;
}

.slot-row {
  border-top: 1px solid #e5e7eb;
  height: 40px;
  position: relative;
}

.slot-row:nth-child(odd) {
  background: #f9fafb;
}

.slot-row:nth-child(even) {
  background: #ffffff;
}

.slot-row:hover {
  background: #e5f2ff;
}

.slot-click-overlay {
  position: absolute;
  inset: 0;
  cursor: crosshair;
}

.selection-overlay {
  position: absolute;
  left: 4px;
  right: 4px;
  background: rgba(37, 99, 235, 0.2);
  border: 2px solid #2563eb;
  border-radius: 0.5rem;
  pointer-events: none;
  z-index: 10;
}

.selection-overlay::before {
  content: '';
  position: absolute;
  top: -2px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 6px solid #2563eb;
}

.selection-overlay::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-bottom: 6px solid #2563eb;
}

.booking-chip {
  position: absolute;
  left: 4px;
  right: 4px;
  border-radius: 0.7rem;
  padding: 0.15rem 0.4rem;
  font-size: 0.72rem;
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: white;
  border: 1px solid #1d4ed8;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
  display: flex;
  flex-direction: column;
  gap: 0.05rem;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.booking-chip[style*="cursor: pointer"]:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.35);
}

.booking-chip.pending {
  background: linear-gradient(135deg, #f97316, #ea580c);
  border-color: #ea580c;
  color: white;
}

.booking-chip-cancelled,
.booking-chip-rejected {
  opacity: 0.5;
  background: #9ca3af !important;
  border-color: #6b7280 !important;
  filter: grayscale(0.6);
}

.booking-chip-title {
  font-weight: 500;
}

.booking-chip-meta {
  font-size: 0.64rem;
  opacity: 0.9;
}

.calendar-help {
  font-size: 0.8rem;
  color: #6b7280;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.calendar-help span {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  display: inline-block;
}

.legend-dot-approved {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
}

.legend-dot-pending {
  background: linear-gradient(135deg, #f97316, #ea580c);
}

.legend-dot-cancelled {
  background: #9ca3af;
}

.month-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  grid-auto-rows: 1fr;
  gap: 0.4rem;
  font-size: 0.8rem;
  height: 100%;
  min-height: 0;
}

.month-day-header {
  text-transform: uppercase;
  font-size: 0.7rem;
  color: #6b7280;
  text-align: center;
}

.month-day-cell {
  border-radius: 0.7rem;
  border: 1px solid #e5e7eb;
  padding: 0.35rem 0.3rem 0.3rem;
  min-height: 80px;
  background: #ffffff;
  display: flex;
  flex-direction: column;
  gap: 0.18rem;
  height: 100%;
}

.month-day-cell.other-month {
  background: #f9fafb;
  opacity: 0.6;
}

.month-day-header-row {
  display: contents;
}

.month-day-number {
  font-size: 0.7rem;
  color: #374151;
}

.month-day-bookings {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  margin-top: 0.2rem;
}

.month-day-booking {
  font-size: 0.65rem;
  padding: 0.15rem 0.3rem;
  border-radius: 0.4rem;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1d4ed8;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: background 0.1s ease, transform 0.1s ease;
}

.month-day-booking[style*="cursor: pointer"]:hover {
  background: #dbeafe;
  transform: translateY(-1px);
}

.month-day-booking.approved {
  background: #eff6ff;
  border-color: #93c5fd;
  color: #1d4ed8;
}

.month-day-booking.pending {
  background: #fff7ed;
  border-color: #fed7aa;
  color: #c2410c;
}

.month-day-booking.pending:hover {
  background: #ffedd5;
}

.month-day-booking-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
  font-size: 0.6rem;
  line-height: 1.3;
}

.month-day-booking-more {
  font-size: 0.6rem;
  color: #6b7280;
  padding: 0.1rem 0.3rem;
  font-style: italic;
}

.list-view {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.list-row {
  display: grid;
  grid-template-columns: 200px minmax(0, 1.6fr) minmax(0, 1.2fr);
  gap: 0.6rem;
  align-items: center;
  font-size: 0.8rem;
  padding: 0.45rem 0.55rem;
  border-radius: 0.8rem;
  border: 1px solid #e5e7eb;
  background: #ffffff;
  transition: background 0.1s ease, border-color 0.1s ease, transform 0.1s ease;
}

.list-row[style*="cursor: pointer"]:hover {
  background: #f9fafb;
  border-color: #2563eb;
  transform: translateY(-1px);
}

.list-row-header {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: #6b7280;
}

.list-row-time {
  color: #374151;
}

.list-row-title {
  font-weight: 500;
  color: #111827;
}

.list-row-space {
  color: #6b7280;
}

.list-empty {
  font-size: 0.85rem;
  color: #6b7280;
  padding: 0.4rem 0.1rem;
}

.pending-list {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  font-size: 0.8rem;
}

.pending-card {
  border-radius: 0.85rem;
  border: 1px solid #e5e7eb;
  background: #ffffff;
  padding: 0.5rem 0.55rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.pending-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.4rem;
}

.pending-title {
  font-size: 0.85rem;
  color: #111827;
}

.pending-meta {
  font-size: 0.72rem;
  color: #374151;
}

.pending-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.3rem;
  margin-top: 0.3rem;
}

.pending-empty {
  font-size: 0.8rem;
  color: #6b7280;
}

.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 40;
}

.modal.hidden {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
}

.modal-content {
  position: relative;
  z-index: 41;
  width: 100%;
  max-width: 420px;
  border-radius: 1rem;
  border: 1px solid #e5e7eb;
  background: #ffffff !important;
  padding: 1rem 1rem 0.9rem;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

.modal-content h2 {
  margin: 0 0 0.7rem;
  font-size: 1.05rem;
  color: #111827 !important;
}

form {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.form-row {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  font-size: 0.8rem;
}

.form-row label {
  color: #374151;
  font-weight: 500;
}

input,
textarea,
select {
  border-radius: 0.6rem;
  border: 1px solid #d1d5db;
  background: #ffffff !important;
  color: #111827 !important;
  padding: 0.35rem 0.5rem;
  font-size: 0.8rem;
  outline: none;
  transition: border-color 0.1s ease, box-shadow 0.1s ease, background 0.1s ease;
}

input:focus,
textarea:focus,
select:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
  background: #ffffff !important;
  color: #111827 !important;
}

.form-value {
  font-size: 0.8rem;
  color: #111827 !important;
  background: #f9fafb;
  padding: 0.35rem 0.5rem;
  border-radius: 0.6rem;
  border: 1px solid #e5e7eb;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 0.4rem;
}

.hint {
  font-size: 0.75rem;
  color: #6b7280;
  line-height: 1.5;
}

.approval-hint {
  font-size: 0.78rem;
  padding: 0.35rem 0.5rem;
  border-radius: 0.65rem;
  border: 1px dashed #f97316;
  background: #fff7ed;
  color: #c2410c;
  margin-top: 0.25rem;
}

.approval-hint.hidden {
  display: none;
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  border: 1px solid #e5e7eb;
  font-size: 0.7rem;
  color: #374151;
  background: #f9fafb;
  font-weight: 500;
}

.tag-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
}

.tag-dot-pending {
  background: #f97316;
}

.tag-dot-approved {
  background: #2563eb;
}

.tag-dot-rejected {
  background: #ef4444;
}

.tag-dot-cancelled {
  background: #9ca3af;
}

.muted {
  color: #6b7280;
  font-size: 0.75rem;
}

/* Master Account Styles */
.pill-master {
  border-color: #7c3aed;
  color: #6d28d9;
  background: #f3e8ff;
}

.master-panel {
  padding: 1rem;
}

.master-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  border-bottom: 2px solid #e5e7eb;
}

.master-tab {
  padding: 0.5rem 1rem;
  border: none;
  background: transparent;
  color: #6b7280;
  cursor: pointer;
  font-size: 0.85rem;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.master-tab:hover {
  color: #111827;
}

.master-tab.active {
  color: #2563eb;
  border-bottom-color: #2563eb;
  font-weight: 500;
}

.master-content {
  min-height: 400px;
}

.users-table,
.whitelist-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  background: #ffffff;
  border-radius: 0.75rem;
  overflow: hidden;
  border: 1px solid #e5e7eb;
}

.users-table thead,
.whitelist-table thead {
  background: #f9fafb;
}

.users-table th,
.whitelist-table th {
  padding: 0.75rem 1rem;
  text-align: left;
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #6b7280;
  border-bottom: 1px solid #e5e7eb;
}

.users-table td,
.whitelist-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #f3f4f6;
  color: #111827;
}

.users-table tr:last-child td,
.whitelist-table tr:last-child td {
  border-bottom: none;
}

.users-table tr:hover,
.whitelist-table tr:hover {
  background: #f9fafb;
}

.users-table td button,
.whitelist-table td button {
  margin-right: 0.5rem;
  font-size: 0.75rem;
  padding: 0.3rem 0.6rem;
}
