/* Reset và font chữ */
body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  margin: 0;
  padding: 0;
  background-color: #f5f7fa;
  color: #333;
  line-height: 1.6;
}

* {
  box-sizing: border-box;
}

h1, h3 {
  margin: 0px;
  padding: 0px;
}

ul,
li {
  list-style: none;
  margin: 0;
  padding: 0;
}

.sidebar-left {
    padding-top: 1rem;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    background-color: #f6f6f6;
    z-index: 100;
    width: 100px;
    box-shadow: 4px 0 10px rgba(0, 0, 0, 0.1);
    text-align: center;
  }

  .sidebar-left.active {
    display: none;
  }

  .nav-side-bar {
    /* display: none; */
    position: absolute;
    top: 0;
    left: 100%;
    width: 300%;
    height: 100%;
    background-color: #fff;
    z-index: 0;
  }

.menu {
  padding-top: 1rem;
}

.menu-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.menu-item {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 4px 12px;
  transition: all 0.3s linear;
}

.menu-item:hover {
  border-left: 4px solid #5FCD6F;
}
.menu-item:hover .menu-item-content{
  color: #5FCD6F;
}

.menu-item:hover .menu-item-content img {
  filter: brightness(0) saturate(100%) invert(68%) sepia(16%) saturate(712%) hue-rotate(75deg) brightness(94%) contrast(89%);
}

.menu-item-content {
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}


.menu-item.active {
  border-left: 4px solid #5FCD6F;
}
.menu-item.active .menu-item-content {
  color: #5FCD6F;
}

.menu-item .menu-item-content img {
  width: 40px;
  height: 40px;
}

.menu-item.active .menu-item-content img {
  filter: brightness(0) saturate(100%) invert(68%) sepia(16%) saturate(712%) hue-rotate(75deg) brightness(94%) contrast(89%);
}

.menu-item span {
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
}

.menu-item.active .nav-side-bar {
  display: block;
}

.nav-side-bar {
  display: none;
  position: absolute;
  top: 0;
  left: 100%;
  width: 300%;
  height: 100%;
  background-color: #fff;
  z-index: 0;
  padding: 10px 16px;
  overflow-y: auto;
  color: #000;
}

.nav-side-bar-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: #000;
  border-bottom: 1px solid #000;
  padding-bottom: 10px;
}

.nav-side-bar-close {
  cursor: pointer;
}

/* Layout chính */
.container {
  /* display: flex;
  min-height: 100vh;
  flex-direction: column;
  margin: 0 auto;
  padding: 16px 76px; */

  height: 100dvh;
  width: 100dvw;
}

.main-content {
  flex-grow: 1;
  padding: 20px;
  margin-left: 300px;
  /* Điều chỉnh theo chiều rộng sidebar */
  transition: margin 0.3s ease;
}

/* Sidebar */
.sidebar {
  width: 300px;
  background: white;
  box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 100;
  overflow-y: auto;
  padding: 20px;
  transform: translateX(-100%);
  transition: transform 0.3s ease;
}

.sidebar.right {
  left: auto;
  right: 0;
  transform: translateX(100%);
}

.sidebar.active {
  transform: translateX(0);
}

.sidebar-toggle {
  position: fixed;
  top: 20px;
  left: 20px;
  z-index: 99;
  background: #3b82f6;
  color: white;
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

.sidebar-toggle.right {
  left: auto;
  right: 20px;
}

/* Phần upload */
/* .upload-section {
  margin: 25px 0;
  padding: 20px;
  background: #f8f9fa;
  border-radius: 8px;
  border: 1px dashed #d1d5db;
}

.upload-label {
  border: 2px solid #3b82f6;
  border-radius: 6px;
  padding: 8px;
  cursor: pointer;
  display: inline-block;
  width: 100%;
  box-sizing: border-box;
  margin-bottom: 10px;
  transition: border 0.3s ease;
  display: flex;
  align-items: center;
  gap: 10px;
}

.upload-label:hover {
  border: 2px solid #00a6ff;
}

.upload-label #select-model-btn {
  background: #3b82f6;
  color: white;
  padding: 4px 8px;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.3s ease;
  white-space: nowrap;
}

.upload-label:hover #select-model-btn {
  background: #00a6ff;
}

.upload-label #model-name {
  font-size: 14px;
  color: #6b7280;
  width: auto;
  display: inline-block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: auto;
}

#upload-btn {
  background: #3b82f6;
  color: white;
  padding: 12px 24px;
  border: none;
  border-radius: 6px;
  font-size: 16px;
  cursor: pointer;
  display: inline-block;
  width: 100%;
} */

.upload-section {
    font-family: Arial, sans-serif;
    max-width: 500px;
    margin: 0 auto;
    text-align: center;
}

.upload-section p {
    text-align: left;
    font-size: 14px;
    color: #000000;
    margin: 10px 0;
}

.upload-label {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    border: 2px dashed #ccc;
    padding: 16px;
    border-radius: 8px;
    background-color: #f9f9f9;
    min-height: 150px;
    width: 100%;
    box-sizing: border-box;
    margin-bottom: 10px;
}

#select-model-btn {
    background-color: #4CAF50;
    color: white;
    padding: 10px 8px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    margin-right: 15px;
    display: flex;
    justify-content: center;
    flex-shrink: 0;
    width: 90px;
}

#select-model-btn:hover {
    background-color: #45a049;
}

#model-name {
    /* margin-left: 10px; */
            font-size: 14px;
            color: #000000;
            word-wrap: break-word;
            word-break: break-all;
            display: -webkit-box;
            -webkit-line-clamp: 3;
            -webkit-box-orient: vertical;
            overflow: hidden;
            text-overflow: ellipsis;
            line-height: 1.2em;
            max-height: 3.6em;
}

#upload-btn {
    background-color: #4CAF50;
    color: white;
    padding: 10px 0;
    border: none;
    border-radius: 5px;
    font-size: 16px;
    cursor: pointer;
    width: 100%;
    margin-top: 10px;
}

#upload-btn:hover {
    background-color: #45a049;
}

#upload-status {
    margin-top: 10px;
    font-size: 14px;
    color: #4CAF50;
}

#model-upload {
    display: none;
}

/* Viewer 3D */
#viewer-container {
  width: 100%;
  height: 100%;
  border: 1px solid #e5e7eb;
  /* margin-top: 25px; */
  border-radius: 8px;
  overflow: hidden;
  background: #f9fafb;
}

/* Panel điều khiển trong sidebar */
/* .control-panel.assign-material {
  display: none;
  position: fixed;
  top: 100px;
  left: 116px;
  background-color: rgba(255, 255, 255, 0.5);
  z-index: 10;
  padding: 16px;
  border-radius: 8px;
} */

.control-panel {
  margin-bottom: 30px;
}

.control-panel h3 {
  margin-top: 0;
  color: #2c3e50;
  font-size: 18px;
  padding-bottom: 10px;
  border-bottom: 1px solid #eee;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.control-panel h3 span#close-material-controls {
  cursor: pointer;
  font-size: 14px;
  color: #3b82f6;
  display: flex;
  align-items: center;

  svg {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    padding: 2px;
  }

  svg:hover {
    background-color: rgba(0, 0, 0, 0.1);
  }
}

.part-assignment {
  margin-top: 15px;
}

#part-type {
  width: 100%;
  padding: 10px;
  border-radius: 4px;
  border: 1px solid #ddd;
  margin-bottom: 10px;
}

#assign-btn {
  width: 100%;
  padding: 10px;
  background: #10b981;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

/* Thư viện vật liệu */
.material-category {
  margin-bottom: 20px;
}

.material-options {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.material-option {
  padding: 10px;
  border: 1px solid #eee;
  border-radius: 4px;
  cursor: pointer;
  text-align: center;
}

.material-preview {
  width: 100%;
  height: 40px;
  border-radius: 3px;
  margin-bottom: 5px;
}

/* Trạng thái */
#upload-status {
  margin-top: 15px;
  padding: 10px;
  border-radius: 4px;
}

#upload-status.info {
  background: #e0f2fe;
  color: #0369a1;
}

#upload-status.success {
  background: #dcfce7;
  color: #166534;
}

#upload-status.error {
  background: #fee2e2;
  color: #991b1b;
}


/* Tải lên File */
.upload-form {
    width: 100%;
    border-radius: 10px;
    background-color: white;
    font-family: Arial, sans-serif;
}

.upload-form p {
    text-align: left;
    font-size: 14px;
    color: #000000;
    margin: 10px 0;
}

.upload-area {
    border: 1px dashed #8C8C8C;
    border-radius: 5px;
    background-color: #F2F2F2;
    height: 150px;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 20px;
    position: relative; /* Để đặt input file ẩn */
}

.upload-area.dragover {
    background-color: #e1f5fe; /* Màu nền khi kéo thả */
    border-color: #4a90e2;
}

.upload-area .choose-file {
    width: 100%;
    display: flex;
    align-items: center;
    margin: 0 15px;
}

.upload-area button {
    background-color: #5FCD6F;
    border: none;
    padding: 10px 20px;
    border-radius: 5px;
    color: white;
    font-size: 14px;
    cursor: pointer;
    width: 100px;
    display: flex;
    flex-shrink: 0;
}

.upload-area button:hover {
    background-color: #4CAF50; /* Đậm hơn một chút khi hover */
}

.upload-area span {
    margin-left: 10px;
    font-size: 13px;
    color: #000000;
    word-wrap: break-word;
    word-break: break-all;
    display: -webkit-box; /* Chuyển thành box để giới hạn dòng */
    -webkit-line-clamp: 3; /* Giới hạn 3 dòng */
    -webkit-box-orient: vertical; /* Định hướng dọc */
    overflow: hidden; /* Ẩn nội dung thừa */
    text-overflow: ellipsis; /* Thêm dấu ... */
    line-height: 1.2em; /* Chiều cao dòng để tính chính xác số dòng */
    max-height: 3.6em; /* 3 dòng x 1.2em */
}

.upload-btn {
    width: 100%;
    background-color: #5FCD6F;
    border: none;
    padding: 10px;
    border-radius: 5px;
    color: white;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
}

.upload-btn:hover {
    background-color: #4CAF50; /* Đậm hơn một chút khi hover */
}

/* Ẩn input file mặc định */
.upload-area input[type="file"] {
    position: absolute;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

/* Danh sách nhà */
.house-list {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: fixed;
    top: 20px;
    right: 15px;
    padding-right: 5px;
    max-height: 325px;
    /* height: 300px; */
    overflow-y: auto;
}

/* Custom Scrollbar cho Chrome, Edge, Safari */
.house-list::-webkit-scrollbar {
    width: 4px; /* Chiều rộng thanh cuộn */
}

.house-list::-webkit-scrollbar-track {
    background: #f1f1f1; /* Màu nền của track (phần đường chạy) */
    border-radius: 10px; /* Bo góc track */
}

.house-list::-webkit-scrollbar-thumb {
    background: #beb8b8; /* Màu của thumb (nút kéo) */
    border-radius: 10px; /* Bo góc thumb */
}

.house-list::-webkit-scrollbar-thumb:hover {
    background: #beb8b8; /* Màu thumb khi hover */
}

.house-image-wrapper {
    overflow: hidden; /* Ẩn phần thừa của hình ảnh */
    margin: 10px 0; /* Khoảng cách giữa các hình */
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: white;
    border-radius: 50%; /* Tạo hình tròn */
    flex-shrink: 0;
    display: flex;
    cursor: pointer;
}

.house-image-wrapper.active img {
    border: 3px solid #01C334;
}

.house-image-wrapper img {
    width: 60px;
    height: 60px;
    object-fit: cover; /* Đảm bảo hình ảnh không bị méo */
    border-radius: 50%; /* Tạo hình tròn */
    overflow: hidden;
    border: 3px solid #b8bdb9;
}

/* ------------------------ */


/* Responsive */
@media (max-width: 768px) {
  .main-content {
    margin-left: 0;
    padding: 15px;
  }

  .sidebar {
    width: 280px;
  }

  .material-options {
    grid-template-columns: 1fr;
  }
}

.selection-mode-btn {
  background: #3b82f6;
  color: white;
  padding: 10px 15px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  margin-bottom: 15px;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.selection-mode-btn.active {
  background: #ef4444;
}

.selection-mode-btn:hover {
  opacity: 0.9;
}

#cancel-selection {
  background: #f59e0b;
  margin-top: 10px;
}

.object-highlight {
  outline: 2px solid #3b82f6;
  outline-offset: 2px;
  transition: outline 0.2s ease;
}

.material-options {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 12px;
}

.material-preview {
  width: 100%;
  height: 80px;
  object-fit: cover;
  border-radius: 4px;
  margin-bottom: 5px;
  border: 1px solid #e5e7eb;
  transition: transform 0.2s;
}

.material-option:hover .material-preview {
  transform: scale(1.05);
  border-color: #3b82f6;
}

.material-option.active .material-preview {
  border: 2px solid #3b82f6;
}

.default_icon_bottom_right {
    position: fixed;
    bottom: 15px;
    right: 15px;
    z-index: 99;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 16px;
}

.default_icon_bottom_right>div {
    display: flex;
    cursor: pointer;
}

.default_icon_bottom_right>div svg {
    width: 30px;
    height: 30px;
}

#open-chat-ai-button {
  display: block;
  /* position: fixed; */

  background: none;
  padding: 0;
  margin: 0;
  border: none;
  cursor: pointer;
  background: #faff11;
  border-radius: 50%;
  overflow: hidden;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

#open-chat-ai-button img {
  width: 60px;
  height: 60px;
  transform: scale(4);
  transform-origin: center top;
}

#chat-iframe {
  display: none;
  position: fixed;
  bottom: 80px;
  right: 0px;
  z-index: 99;
  border: none;
  border-radius: 10px;
  /* box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2); */
  transform: translateX(100%);
  transition: transform .5s ease;
  width: 450px;
  height: 250px;
}

#view-controls button {
  background: #3b82f6;
  color: white;
  padding: 10px 15px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

#view-controls button:hover {
  background: #00a6ff;
}

@media (max-width: 768px) {
  .container {
    /* padding: 6px 60px; */
  }

  .sidebar-toggle {
    top: 10px;
    left: 10px;
    width: 35px;
    height: 35px;
  }

  h1 {
    font-size: 24px;
    padding: 3px 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

.aging-control {
  /* padding: 15px; */
  border-radius: 8px;
  /* margin-top: 20px; */
  position: fixed;
  display: flex;
  justify-content: center;
  top: 15px;
  left: 0;
  width: 100%;
}

.slider-container {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 10px 0;
  width: calc(100dvw - 215px);
  background: #f5f5f5;
padding: 10px;
border-radius: 8px;

}

#aging-slider {
  flex-grow: 1;
}

.aging-effects {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.7);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  color: white;
  font-family: Arial, sans-serif;
}

.loading-spinner {
  border: 5px solid #f3f3f3;
  border-top: 5px solid #3498db;
  border-radius: 50%;
  width: 50px;
  height: 50px;
  animation: spin 1s linear infinite;
  margin-bottom: 15px;
}

.loading-text {
  font-size: 18px;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}