/* ================================================= /
/ CẤU HÌNH BIẾN (Dựa trên code gốc: Header = 50px) /
/ ================================================= */
$header-height: 75px;
$sidebar-width: 200px;
$toolbar-width: 70px;

/* ================================================= /
/ GLOBAL/RESET - BẮT BUỘC CHO LAYOUT FULLSCREEN /
/ ================================================= */

{
box-sizing: border-box;
margin: 0;
padding: 0;
font-family: sans-serif;
}

body, html {
/* QUAN TRỌNG: Thiết lập chiều cao đầy đủ cho body/html */
height: 100%;
background-color: #f0f0f0;
margin: 0;
padding: 0;

/* Đẩy toàn bộ nội dung xuống dưới header cố định */
padding-top: $header-height !important; 

/* BỎ overflow-x: hidden nếu bạn muốn cuộn ngang, nhưng thường nên giữ */
overflow-x: hidden; 

}

/* KHẮC PHỤC XUNG ĐỘT SAPO /
.main-content, .site-main, .site-content, #sapo-main-content {
padding-top: 0 !important;
padding-bottom: 0 !important;
/ KHÔNG BỎ overflow: hidden!important; nếu layout cần cố định */
}

/* ================================================= /
/ CODE GỐC CỦA BẠN (GIỮ NGUYÊN) /
/ ================================================= */

/* Header */
.header {
display: flex;
justify-content: space-between;
align-items: center;
padding: 10px 20px;
background-color: #007bff;
color: white;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
height: $header-height;

/* QUAN TRỌNG: Nếu đây là Header cố định */
position: fixed;
top: 0;
left: 0;
width: 100%;
z-index: 9999;

}
.header h1 {
font-size: 1.25em;
font-weight: bold;
}
.header-logo {
display: flex;
align-items: center;
font-size: 1.5em;
font-weight: bold;
}
.header-logo img {
height: 30px;
margin-right: 5px;
}

/* Editor Container */
.editor-container {
display: flex;

/* Đã sửa từ calc(100vh - 50px) thành calc(100vh - $header-height) */
/* Và thêm !important để tránh bị ghi đè */
height: calc(100vh - $header-height) !important; 

position: relative;
width: 100%; /* Đảm bảo chiếm toàn bộ chiều rộng */

}

/* Sidebar */
.sidebar {
width: $sidebar-width;
background-color: #fff;
padding: 10px;
overflow-y: auto;
border-right: 1px solid #ccc;

/* QUAN TRỌNG: Kéo dài hết chiều cao của .editor-container */
height: 100%; 

}
.sidebar-section {
margin-bottom: 20px;
padding-bottom: 10px;
border-bottom: 1px solid #eee;
display: none;
}
.sidebar-section.active {
display: block;
}
.sidebar h3 {
font-size: 1.1em;
color: #333;
margin-bottom: 10px;
}

/* Nav Tab */
.sidebar-nav {
display: flex;
justify-content: space-around;
margin-bottom: 10px;
border-bottom: 2px solid #ddd;
}
.nav-tool {
padding: 8px;
cursor: pointer;
text-align: center;
flex-grow: 1;
transition: all 0.2s;
color: #555;
font-size: 0.9em;
}
.nav-tool.active {
border-bottom: 3px solid #007bff;
color: #007bff;
font-weight: bold;
}
.nav-tool:hover {
background-color: #f5f5f5;
}

/* ----- Mới: Grid cho Danh mục và Mockup chi tiết (3 cột) ----- */
.grid-categories,
.grid-mockups {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 10px;
text-align: center;
}

.category-option,
.mockup-option {
cursor: pointer;
padding: 5px;
transition: background-color 0.2s;
border-radius: 4px;
border: 1px solid #eee;
}
.category-option:hover,
.mockup-option:hover {
background-color: #f0f8ff;
}
.category-option img,
.mockup-option img {
width: 100%;
height: auto;
border-radius: 4px;
display: block;
}
.category-name,
.mockup-name {
font-size: 0.7em;
margin-top: 5px;
color: #555;
}
/* ---------------------------------------------------------------- */

/* Grid cho Designs (3 cột, giữ nguyên style gốc) */
.grid-designs {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 10px;
text-align: center;
}
.design-option {
cursor: pointer;
padding: 5px;
border-radius: 4px;
}
.design-option:hover {
background-color: #f0f8ff;
}
.design-option img {
width: 100%;
max-width: 60px;
height: auto;
border-radius: 4px;
}
.design-option p {
font-size: 0.7em;
margin-top: 5px;
color: #555;
}

/* Main Editor Area */
/* ===== KHU VỰC CHÍNH (TRUNG TÂM) ===== */
.editor-center {
  flex: 1;
  background: #f5f5f5;
  border-radius: 6px;
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
  overflow: hidden;


/* QUAN TRỌNG: Kéo dài hết chiều cao của .editor-container */
height: 100%; 

/* BẮT BUỘC: Fix lỗi Flexbox co lại khi có overflow */
min-height: 0; 

}

/* Vùng mockup áo */
.shirt-area {
  position: relative;
  background: #ddd;
  width: 500px;
  height: 400px;
  display: flex;
  justify-content: center;
  align-items: center;
}

.shirt-base {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: white;
z-index: 1;
}
#main-mockup {
width: 100%;
height: 100%;
object-fit: contain;
position: relative;
z-index: 2;
}
#design-layer {
position: absolute;
top: 15%;
width: 70%;
height: 55%;
z-index: 3;
overflow: visible;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}

/* Draggable Elements /
.draggable {
position: absolute;
cursor: grab;
transition: border 0.1s ease;
user-select: none;
border-radius: 4px;
}
.draggable.active {
border: 2px dashed #007bff;
padding: 5px;
}
.draggable:hover {
cursor: move;
}
.draggable img {
width: 100%;
height: 100%;
object-fit: contain;
pointer-events: none;
}
.text-element {
font-size: 20px;
font-family: Arial;
white-space: nowrap;
}
/ Handles */
.handle {
position: absolute;
width: 12px;
height: 12px;
background: #007bff;
border: 1px solid white;
border-radius: 50%;
cursor: se-resize;
z-index: 100;
}
.handle.tl { top: -6px; left: -6px; cursor: nwse-resize; }
.handle.tr { top: -6px; right: -6px; cursor: nesw-resize; }
.handle.bl { bottom: -6px; left: -6px; cursor: nesw-resize; }
.handle.br { bottom: -6px; right: -6px; cursor: nwse-resize; }
.handle.r { top: 50%; right: -6px; margin-top: -6px; cursor: ew-resize; }
.handle.rot { top: -20px; left: 50%; margin-left: -6px; cursor: grab; }

/* Right Toolbar (Đã tăng kích thước để SVG icon rõ hơn) */
/* ===== BỐ CỤC 3 CỘT ===== */
.editor-container {
  display: flex;
  align-items: stretch;
  height: 420px; /* Chiều cao toàn màn hình */
  overflow: hidden;
}

/* ===== TOOLBAR PHẢI ===== */
/* ===== TOOLBAR PHẢI ===== */
.right-toolbar {
  width: 70px;
  background: #fff;
  border-left: 1px solid #eee;
  border-radius: 0 6px 6px 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 0;
  height: 100%;
}

.right-toolbar .tool {
  margin: 8px 0;
  cursor: pointer;
  transition: transform 0.2s;
}
.right-toolbar .tool:hover {
  transform: scale(1.1);
}


/* Text Tools Popup */
#text-tools-popup {
position: absolute;
background-color: #333;
padding: 8px;
border-radius: 5px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
z-index: 9999;
display: none;
gap: 5px;
align-items: center;
}
#text-tools-popup.active {
display: flex;
}
#text-tools-popup input[type="color"],
#text-tools-popup input[type="number"],
#text-tools-popup select {
padding: 4px;
border-radius: 3px;
border: 1px solid #555;
height: 30px;
}
#btn-bold {
font-weight: bold;
padding: 4px 8px;
background: #555;
color: white;
border: none;
border-radius: 3px;
cursor: pointer;
height: 30px;
}
#btn-bold.active {
background-color: #007bff;
}

/* Message Box */
#message-box {
z-index: 10000;
}

/* Upload Section */
.custom-file-upload {
border: 1px solid #ccc;
display: block;
padding: 8px 12px;
cursor: pointer;
background-color: #f9f9f9;
border-radius: 4px;
text-align: center;
transition: background-color 0.2s;
}
.custom-file-upload:hover {
background-color: #eee;
}




/* ========================= */
/* Ô chọn màu áo (gọn gàng) */
/* ========================= */
.color-swatch {
  width: 26px;
  height: 26px;
  border-radius: 4px;
  border: 1px solid #bbb;
  cursor: pointer;
  transition: transform 0.1s ease, border-color 0.2s;
}
.color-swatch:hover {
  transform: scale(1.1);
  border-color: #007bff;
}
.color-swatch.active {
  border: 2px solid #007bff;
}

/* ========================= */
/* Danh mục có icon (thay ảnh) */
/* ========================= */
.category-option {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: flex-start;
  padding: 8px;
  border-radius: 6px;
  border: 1px solid #eee;
  cursor: pointer;
  transition: all 0.2s ease;
  background-color: #fff;
}

.category-option i {
  font-size: 1.3rem;
  width: 24px;
  text-align: center;
}

.category-option:hover {
  background-color: #f5faff;
  border-color: #007bff;
}

.category-option p {
  font-size: 0.9em;
  color: #333;
  margin: 0;
  font-weight: 500;
}

.grid-categories {
  display: flex;
  flex-direction: column;
  gap: 6px;
}





/* ===== SIDEBAR TRÁI ===== */
.sidebar {
  width: 320px;
  display: flex;
  flex-direction: column;
  border-right: 1px solid #e0e0e0;
  background: #fff;
}

/* Thanh menu cố định trên cùng */
.sidebar-nav {
  flex-shrink: 0;
  display: flex;
  justify-content: space-around;
  border-bottom: 1px solid #e0e0e0;
  background: #f9fafb;
  position: sticky;
  top: 0;
  z-index: 2;
} 
/* Phần nội dung cuộn */
.sidebar-section {
  flex-grow: 1;
  overflow-y: auto;
  padding: 12px 16px;
  height: calc(100vh - 50px); /* trừ phần nav cố định */
}

.sidebar-section::-webkit-scrollbar {
  width: 6px;
}
.sidebar-section::-webkit-scrollbar-thumb {
  background: #ccc;
  border-radius: 3px;
}
.sidebar-section::-webkit-scrollbar-thumb:hover {
  background: #999;
}
/* Hai view này nằm trọn trong sidebar */
.mockup-detail-view,
.design-detail-view {
  position: relative;
  flex: 1;
  display: none;
  flex-direction: column;
  overflow-y: auto;
}

/* Khi JS bật class 'hidden' thì ẩn, ngược lại hiển thị đúng vùng */
.mockup-detail-view:not(.hidden),
.design-detail-view:not(.hidden) {
  display: flex !important;
}



#main-mockup {
  height: auto;
  display: block;
}

#design-layer {
  position: absolute;
  inset: 0;
  z-index: 10;
  pointer-events: auto;
}
#text-tools-popup {
  position: fixed;
  display: flex;
  align-items: center;
  gap: 6px;
  background: #333;
  color: #fff;
  padding: 6px 8px;
  border-radius: 6px;
  z-index: 9999;
  visibility: hidden;
  opacity: 0;
  transition: opacity 0.2s ease;
}

#text-tools-popup.active {
  visibility: visible;
  opacity: 1;
}

#text-tools-popup input,
#text-tools-popup select,
#text-tools-popup button {
  background: #fff;
  color: #000;
  border: none;
  border-radius: 4px;
  padding: 3px 6px;
}

#btn-bold.active {
  background: #2563eb;
  color: #fff;
}