/* css/style.css */
body {
  margin: 0;
}

canvas {
  display: block;
}

#info-panel {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 250px;
  background-color: rgba(255, 255, 255, 0.9);
  border-radius: 10px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
  padding: 10px 20px;
  font-family: sans-serif;
  z-index: 10;
}

#info-panel h3 {
  margin-top: 5px;
  border-bottom: 1px solid #ccc;
  padding-bottom: 5px;
}

#info-panel p {
  margin: 10px 0;
}

#info-panel button {
  width: 100%;
  padding: 10px;
  margin-top: 10px;
  border: 1px solid #ccc;
  border-radius: 5px;
  cursor: pointer;
  background-color: #007bff;
  color: white;
  font-size: 14px;
  font-weight: bold;
}

#info-panel button:hover {
  background-color: #0056b3;
}

.hidden {
  display: none;
}

/* Label Styles */
#label-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  pointer-events: none; /* Cho phép click xuyên qua container này */
}

.label {
  position: absolute;
  background-color: rgba(0, 0, 0, 0.7);
  color: white;
  padding: 5px 10px;
  border-radius: 5px;
  font-family: sans-serif;
  font-size: 14px;
  white-space: nowrap;
  transform: translate(-50%, -50%); /* Căn giữa nhãn vào điểm tọa độ */
  user-select: none; /* Không cho phép chọn text */
}

/* Kiểu riêng cho nhãn tọa độ */

/* TẠO MỚI: Kiểu riêng cho nhãn phòng chi tiết */
.room-label {
  position: absolute;
  background-color: rgba(20, 20, 20, 0.6);
  color: #f0f0f0;
  padding: 2px 6px;
  border-radius: 3px;
  font-family: sans-serif;
  font-size: 10px; /* Nhỏ hơn đáng kể */
  white-space: nowrap;
  pointer-events: none;
}

/* TẠO MỚI: Style cho bảng điều khiển label */
#label-controls {
  position: fixed;
  top: 20px;
  right: 20px;
  background-color: rgba(255, 255, 255, 0.9);
  border-radius: 10px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
  padding: 10px 20px;
  font-family: sans-serif;
  z-index: 10;
  width: 250px;
}

#label-controls h4 {
  margin-top: 5px;
  border-bottom: 1px solid #ccc;
  padding-bottom: 5px;
}

#label-controls div {
  margin: 8px 0;
}

/* Style cho bảng điều khiển locker labels trong View Inside */
#locker-label-controls {
  position: fixed;
  top: 20px;
  right: 20px;
  background-color: rgba(255, 255, 255, 0.95);
  border-radius: 10px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
  padding: 10px 20px;
  font-family: sans-serif;
  z-index: 10;
  width: 200px;
}

#locker-label-controls h4 {
  margin-top: 5px;
  margin-bottom: 8px;
  border-bottom: 1px solid #ccc;
  padding-bottom: 5px;
  color: #1a5276;
}

#locker-label-controls div {
  margin: 8px 0;
}

#module-detail-panel {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 280px;
  background-color: #ffffff;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
    Arial, sans-serif;
  overflow: hidden;
  transition: opacity 0.3s ease, transform 0.3s ease;
  transform: translateX(20px);
  opacity: 0;
}

#module-detail-panel:not(.hidden) {
  transform: translateX(0);
  opacity: 1;
}

.panel-sidebar {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 10px;
  background-color: #f7a8b8; /* Màu hồng mặc định */
  transition: background-color 0.3s ease;
}

/* Thêm các màu khác cho sidebar */
.panel-sidebar.pink {
  background-color: #f7a8b8;
}
.panel-sidebar.yellow {
  background-color: #fde68a;
}

.panel-content {
  padding: 20px 20px 20px 30px; /* Thêm padding trái để không bị đè lên sidebar */
}

.panel-content h2 {
  margin: 0 0 24px 0;
  font-size: 28px;
  font-weight: 700;
  color: #333;
}

.detail-item {
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.detail-label {
  font-size: 13px;
  color: #888;
  margin-bottom: 6px;
}

#module-price {
  font-size: 22px;
  font-weight: 600;
  color: #111;
}

.pill {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 16px;
  font-size: 14px;
  font-weight: 500;
  color: #333;
}

.pill-blue {
  background-color: #dbeafe;
  color: #1e40af;
}

.pill-pink {
  background-color: #fce7f3;
  color: #9d2449;
}

.pill-yellow {
  background-color: #fef3c7;
  color: #92400e;
}

.pill-gray {
  background-color: #e5e7eb;
  color: #374151;
}

#module-tooltip {
  position: fixed; /* Định vị theo cửa sổ trình duyệt */
  background-color: rgba(0, 0, 0, 0.8);
  color: white;
  padding: 6px 12px;
  border-radius: 6px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  z-index: 100; /* Luôn nổi trên cùng */

  /* Rất quan trọng: để con trỏ chuột có thể "xuyên qua" tooltip và tiếp tục raycast vào các module bên dưới */
  pointer-events: none;

  /* Hiệu ứng mượt mà */
  transition: opacity 0.2s ease-out;
  opacity: 0;

  /* Dịch chuyển nhẹ để không bị che bởi con trỏ */
  transform: translate(15px, 15px);
}

#module-tooltip:not(.hidden) {
  opacity: 1;
}

/* Occupancy Stats Styles */
#occupancy-stats {
  margin: 10px 0;
  padding: 10px;
  background-color: #f9f9f9;
  border-radius: 8px;
}

.stats-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 5px 0;
}

.stat-label {
  font-size: 13px;
  color: #666;
}

.stat-value {
  font-weight: 600;
  font-size: 14px;
}

.stat-available {
  color: #22c55e;
}

.stat-occupied {
  color: #f59e0b;
}

#occupancy-bar {
  margin-top: 10px;
  height: 8px;
  background-color: #22c55e;
  border-radius: 4px;
  overflow: hidden;
}

#occupancy-fill {
  height: 100%;
  background-color: #f59e0b;
  transition: width 0.3s ease;
}

/* Pill status colors */
.pill-available {
  background-color: #dcfce7;
  color: #166534;
}

.pill-occupied {
  background-color: #fef3c7;
  color: #92400e;
}

.pill-overdue {
  background-color: #fee2e2;
  color: #991b1b;
}

/* Data loading state */
.loading {
  opacity: 0.5;
}

/* Export PDF Button */
.export-btn {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
  border: none !important;
  color: white !important;
  font-weight: 600 !important;
  transition: all 0.3s ease !important;
}

.export-btn:hover {
  background: linear-gradient(135deg, #5a67d8 0%, #6b46c1 100%) !important;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.export-btn:disabled {
  background: #ccc !important;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.export-btn.loading {
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.6;
  }
}

/* ============================================
   Top Bar (Language + Export PDF)
   ============================================ */
#top-bar {
  position: fixed;
  top: 20px;
  left: 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 100;
  font-family: sans-serif;
}

#language-selector {
  position: relative;
}

.language-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border: 1px solid #ddd;
  border-radius: 8px;
  background: white;
  color: #333;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  transition: all 0.2s ease;
}

.language-btn:hover {
  background: #f5f5f5;
  border-color: #ccc;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.language-btn img {
  width: 24px;
  height: 18px;
  border-radius: 3px;
  object-fit: cover;
}

.dropdown-arrow {
  font-size: 10px;
  margin-left: 4px;
  transition: transform 0.2s ease;
}

#language-selector:hover .dropdown-arrow {
  transform: rotate(180deg);
}

.language-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 8px;
  background: white;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  overflow: hidden;
  min-width: 150px;
}

.language-dropdown.hidden {
  display: none;
}

.language-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.language-option:hover {
  background-color: #f0f4f8;
}

.language-option img {
  width: 24px;
  height: 18px;
  border-radius: 3px;
  object-fit: cover;
}

.language-option span {
  color: #2c3e50;
  font-size: 14px;
}

.language-option.active {
  background-color: #e8f4fc;
}

.language-option.active span {
  font-weight: 600;
  color: #2980b9;
}

/* Top Bar Button (Export PDF) */
.top-bar-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border: 1px solid #ddd;
  border-radius: 8px;
  background: white;
  color: #333;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  transition: all 0.2s ease;
}

.top-bar-btn:hover {
  background: #f5f5f5;
  border-color: #ccc;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.top-bar-btn.loading {
  opacity: 0.7;
  cursor: wait;
  animation: pulse 1.5s infinite;
}
