/*CAMERA=======================================CAMERA*/

/* Cấu trúc chung */
.camera-body {
  position: relative;
  width: 100%;
  border-radius: 10px;
  padding: 20px;
  display: flex;
  place-items: center;
  flex-direction: column;
  box-sizing: border-box; /* Đảm bảo padding không ảnh hưởng đến chiều cao của container */
}

.camera-body .camera-container {
  position: relative;
  width: 900px;
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  box-sizing: border-box; /* Đảm bảo padding không ảnh hưởng đến chiều cao của container */
}

/* Header - Căn chỉnh layout và countdown */
.camera-body .header {
  display: flex;
  justify-content: flex-start;
  width: 100%; /* Đảm bảo header chiếm toàn bộ chiều rộng */
}

.camera-body .layout-countdown {
  display: flex;
  justify-content: space-between;
  width: 100%;
  font-size: 16px;
  font-weight: 500;
  color: #636363;
}

.camera-body #layoutText {
  text-align: left;
  flex: 1;
}

.camera-body #countdownText {
  text-align: right;
  flex: 1;
}

/* Camera content */
.camera-body .camera-content {
  display: flex;
  justify-content: space-between;
  position: relative;
}

/* Camera view */
.camera-body .camera-view {
  width: 590px;
  height: 446px;
  background-color: #ccc;
  border-radius: 10px;
}

.camera-body #cameraVideo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 10px;
}

.camera-body #outputCanvas {
  width: 100%;
  height: 100%;
  border-radius: 10px;
  display: block;
}

.camera-body .button-container {
  width: 297px;
  height: 446px;
  border-radius: 10px;
}

/* Khung chứa 2 nút nằm ngang */
.camera-body .tab-header {
  margin-top: 12px;
  display: flex; /* Sắp xếp các nút theo chiều ngang */
  gap: 10px; /* Khoảng cách giữa các nút */
  width: fit-content; /* Đảm bảo chiều rộng phụ thuộc vào nội dung */
}

/* Nút Background và Filter */
.camera-body .select-btn {
  padding: 8px 30px; /* Thêm padding cho nút */
  font-size: 1rem;
  font-weight: bold;
  border: 2px solid #222; /* Viền đen */
  border-radius: 30px; /* Viền bo tròn */
  background-color: none; /* Nền trắng */
  color: #222; /* Màu chữ đen */
  cursor: pointer; /* Trỏ chuột vào nút */
  transition: all 0.3s ease; /* Thêm hiệu ứng chuyển đổi mượt mà */
  white-space: nowrap; /* Đảm bảo chữ không bị xuống dòng */
  display: inline-flex; /* Đảm bảo nút có thể wrap content */
  align-items: center; /* Căn chỉnh chữ ở giữa */
  justify-content: center; /* Căn chỉnh chữ ở giữa */
  height: 32px;
  min-width: 100px;
}

/* Khi hover vào nút */
.camera-body .select-btn:hover {
  background-color: #222; /* Nền đen khi hover */
  color: white; /* Chữ trắng khi hover */
}

/* Khi nút được chọn (class 'selected') */
.camera-body .select-btn.selected {
  background-color: #222; /* Nền đen khi chọn */
  color: white; /* Chữ trắng khi chọn */
  border-color: #222; /* Giữ viền đen khi chọn */
}

/* Khi nút không được chọn */
.camera-body .select-btn:not(.selected) {
  background-color: white; /* Nền trắng khi không chọn */
  color: #222; /* Chữ đen khi không chọn */
  border-color: #222; /* Viền đen khi không chọn */
}

/* Grid chứa các background/filter */
.camera-body .grid-container {
  width: 100%;
  margin: 0 auto;
}

.camera-body #filter-grid-container {
  width: 100%;
  margin: 0 auto;
  min-height: 300px;
  border-radius: 8px;
  padding: 10px;
}

.camera-body #image-grid {
  margin-top: 15px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.camera-body .image-item-bg {
  width: 90%;
  height: 90%;
  padding-top: 90%; /* giữ tỷ lệ vuông */
  position: relative;
  border-radius: 10px;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  cursor: pointer;
  border: 2px solid transparent;
  box-sizing: border-box; /* BẮT BUỘC để border không làm to ra */
  transition: box-shadow 0.3s ease, outline 0.3s ease;
}

.camera-body .image-item-bg.selected {
  border: 2px solid #ffdd00; /* Thêm viền vàng */
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1), 0 0 10px rgba(255, 221, 0, 0.6); /* Thêm bóng đổ mờ với màu vàng */
}

.camera-body .image-item-bg img,
.image-item-bg span {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 100%;
  object-fit: cover; /* Đảm bảo ảnh lấp đầy khung */
  display: block;
  align-items: center;
  justify-content: center;
}

.camera-body .image-item-bg img[loading="lazy"] {
  opacity: 1; /* Hiển thị ảnh khi đã tải */
}

.camera-body .delete-btn {
  position: absolute;
  top: 0px;
  align-items: center;
  justify-content: center;
  display: flex;
  color: black;
  right: 0px;
  background: none; /* Bỏ nền cho nút */
  border: none;
  width: 24px;
  height: 24px;
  cursor: pointer; /* Đảm bảo nút xóa không bị che khuất */
}

.camera-body .delete-btn img {
  width: 100%; /* Đảm bảo ảnh lấp đầy nút */
  height: 100%; /* Đảm bảo ảnh lấp đầy nút */
  object-fit: contain; /* Đảm bảo icon không bị méo */
}

.camera-body .upload-btn {
  border: 2px solid #222222; /* Bạn có thể thay đổi màu sắc của border */
  border-radius: 10px;
  width: 90%;
  display: flex;
  position: relative;
  justify-content: center;
  align-items: center;
  cursor: pointer;
}

.camera-body .upload-btn img {
  width: 100%; /* Kích thước icon */
  height: 100%;
  padding: 30%;
  object-fit: contain;
}

.camera-body .no-background {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(45deg, #f0f0f0 25%, transparent 25%), 
              linear-gradient(-45deg, #f0f0f0 25%, transparent 25%), 
              linear-gradient(45deg, transparent 75%, #f0f0f0 75%), 
              linear-gradient(-45deg, transparent 75%, #f0f0f0 75%);
  background-size: 20px 20px;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
  border: 2px solid #ddd;
}

.camera-body .no-background .no-bg-icon {
  font-size: 24px;
  color: #666;
  font-weight: bold;
}

.camera-body .no-background:hover {
  border-color: #007bff;
  transform: scale(1.05);
}

.camera-body .no-background.selected {
  border-color: #007bff;
  box-shadow: 0 0 10px rgba(0,123,255,0.5);
}

/* Các tùy chọn countdown nằm dưới phần video và tab */
.camera-body .countdown-options {
  display: flex;
  justify-content: center;
  gap: 10px;
}

.camera-body .countdown-btn {
  background-color: #ddd;
  border: none;
  padding: 8px 30px;
  font-size: 1rem;
  cursor: pointer;
  border-radius: 25px;
  transition: background-color 0.3s ease;
}

.camera-body .countdown-btn.selected {
  background-color: #000000; /* Màu nền khi được chọn */
  color: white;
}

.camera-body .countdown-btn:hover {
  background-color: #000000;
  color: white;
}

/* Nút Snap Now */
.camera-body .snap-btn {
  background-color: #ffdd00;
  border: none;
  padding: 16px 40px;
  font-size: 1.2rem;
  font-weight: bold;
  color: #222222;
  border-radius: 30px;
  cursor: pointer;
  transition: background-color 0.3s ease;
  align-self: center;
}

.camera-body .snap-btn:disabled {
  background-color: #ddd;
  color: #aaa;
  cursor: not-allowed;
}

.camera-body .snap-btn:hover:not(:disabled) {
  background-color: #ffd200;
}

/* filter */
.camera-body #filter-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.camera-body .image-item-filter {
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  aspect-ratio: 1 / 1.5;
  position: relative;
  border: 2px solid transparent;
  transition: border-color 0.3s ease;
}

.camera-body .image-item-filter img {
  width: 100%;
  aspect-ratio: 1 / 1;
  height: auto;
  object-fit: cover; /* Thay đổi từ contain sang cover */
  border-radius: 12px;
  display: block; /* Đảm bảo không có khoảng trắng */
  border: 2px solid transparent; /* Viền trong suốt mặc định */
  transition: border-color 0.3s ease;
}

.camera-body .filter-label {
  font-size: 12px;
  padding: 2px 0;
  color: #333;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 500;
  text-align: center;
  line-height: 1.2;
}





/* Custom styling cho nút "No filter" mới */
.camera-body .image-item-filter[data-filter="none"] .no-filter-icon-container {
  border: 2px solid #000000;
  transition: border-color 0.3s ease;
  width: 100%;
  aspect-ratio: 1 / 1; /* Giống với img của các filter khác */
  height: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  background: white;
  border-radius: 12px;
}

.camera-body .image-item-filter[data-filter="none"] .no-filter-icon-container img {
  transition: all 0.3s ease;
  width: 30% !important;
  height: 30% !important;
  object-fit: contain;
}

/* Khi "No filter" được chọn */
.camera-body .image-item-filter[data-filter="none"].selected .no-filter-icon-container,
.camera-body .image-item-filter[data-filter="none"] .no-filter-icon-container.selected-thumbnail-only {
  border: 2px solid #ffdd00;
  box-shadow: 0 2px 2px rgba(0, 123, 255, 0.3);
}

/* Sửa lại viền cho tất cả filter items - chỉ bo thumbnail, không bo cả item */
.camera-body .image-item-filter {
  border: none !important; /* Bỏ viền của item */
  padding: 0 !important; /* Bỏ padding để viền không bị lệch */
}

.camera-body .image-item-filter .no-filter-icon-container {
  border: 2px solid transparent; /* Viền trong suốt mặc định */
  border-radius: 12px;
  transition: border-color 0.3s ease;
  margin: 0 !important; /* Bỏ margin để viền không bị lệch */
}

/* Viền đen cho "No filter" khi không chọn */
.camera-body .image-item-filter[data-filter="none"] .no-filter-icon-container {
  border: 2px solid #000000;
}

/* Viền vàng khi được chọn */
.camera-body .image-item-filter img.selected-thumbnail-only,
.camera-body .image-item-filter .no-filter-icon-container.selected-thumbnail-only {
  border: 2px solid #ffdd00 !important;
  box-shadow: 0 2px 2px rgba(0, 123, 255, 0.3);
}

/* Đảm bảo text label hiển thị đúng cho tất cả filter items */
.camera-body .image-item-filter .filter-label {
  font-size: 12px;
  padding: 2px 0;
  color: #333 !important;
  height: 20px;
  display: flex !important;
  align-items: center;
  justify-content: center;
  font-weight: 500;
  text-align: center;
  line-height: 1.2;
  margin-top: 4px;
  background: transparent;
  position: relative;
  z-index: 10;
}

/* ============================================================================
   RESPONSIVE DESIGN - CAMERA
   ============================================================================ */

/* Desktop (1200px and above) */
@media (min-width: 1200px) {
  .camera-body .camera-container {
    width: 900px;
  }
  
  .camera-body .camera-view {
    width: 590px;
    height: 446px;
  }
  
  .camera-body .button-container {
    width: 297px;
    height: 446px;
  }
  
  .camera-body .select-btn {
    font-size: 1rem;
    padding: 8px 30px;
  }
  
  .camera-body .snap-btn {
    font-size: 1.2rem;
    padding: 16px 40px;
  }
}

/* Tablet (768px - 1199px) */
@media (min-width: 768px) and (max-width: 1199px) {
  .camera-body .layout-countdown {
    font-size: 15px;
  }
  
  .camera-body .camera-container {
    width: 95%;
    max-width: 800px;
  }
  
  .camera-body .camera-view {
    width: 60%;
    height: calc(60% * 446 / 590); /* Giữ tỷ lệ 590:446 */
    border-radius: 8px;
  }
  
  .camera-body .button-container {
    width: 38%;
    height: calc(60% * 446 / 590); /* Cùng chiều cao với camera view */
  }
  
  .camera-body .tab-header {
    margin-top: 8px;
    gap: 6px;
  }
  
  .camera-body .select-btn {
    font-size: 0.85rem;
    padding: 5px 20px;
    height: 26px;
    min-width: 80px;
  }
  
  .camera-body #image-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    margin-top: 10px;
  }
  
  .camera-body .countdown-options {
    gap: 6px;
  }
  
  .camera-body .countdown-btn {
    padding: 5px 20px;
    font-size: 0.85rem;
  }
  
  .camera-body .snap-btn {
    font-size: 1rem;
    padding: 12px 30px;
  }
}

/* Phone (below 768px) */
@media (max-width: 767px) {
  .camera-body .layout-countdown {
    font-size: 14px;
  }
  
  .camera-body .camera-container {
    width: 95%;
    padding: 15px;
  }
  
  .camera-body .camera-content {
    flex-direction: column;
    gap: 15px;
  }
  
  .camera-body .camera-view {
    width: 100%;
    height: calc(100% * 446 / 590); /* Giữ tỷ lệ 590:446 */
    max-height: 300px; /* Giới hạn chiều cao tối đa */
  }
  
  .camera-body .button-container {
    width: 100%;
    height: auto;
  }
  
  .camera-body .tab-header {
    justify-content: center;
    margin-top: 8px;
  }
  
  .camera-body .select-btn {
    font-size: 0.85rem;
    padding: 5px 20px;
    height: 26px;
    min-width: 80px;
  }
  
  .camera-body #image-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    margin-top: 10px;
  }
  
  .camera-body .countdown-options {
    gap: 6px;
  }
  
  .camera-body .countdown-btn {
    padding: 5px 20px;
    font-size: 0.85rem;
  }
  
  .camera-body .snap-btn {
    font-size: 1rem;
    padding: 12px 30px;
    width: 80%;
    max-width: 250px;
  }
}

/* Small Phone (below 480px) */
@media (max-width: 480px) {
  .camera-body .layout-countdown {
    font-size: 13px;
  }
}

/* Extra Small Phone (below 360px) */
@media (max-width: 360px) {
  .camera-body .layout-countdown {
    font-size: 12px;
  }
}

/* Responsive cho layout-countdown - thêm trực tiếp */
@media (max-width: 1024px) {
  .layout-countdown {
    font-size: 15px;
  }
}

@media (max-width: 768px) {
  .layout-countdown {
    font-size: 14px;
  }
}

@media (max-width: 480px) {
  .layout-countdown {
    font-size: 13px;
  }
}

@media (max-width: 360px) {
  .layout-countdown {
    font-size: 12px;
  }
}
