/* =========================================
   1. GLOBAL VARIABLES & UTILITIES
   ========================================= */
:root {
  --color-brown: #8B4513;
  /* Màu nâu chủ đạo */
  --color-orange: #fd7e14;
  /* Màu cam Bootstrap */
  --color-orange-active: #F9731E;
  /* Màu cam đậm hơn cho trạng thái active */
  --bg-gray-light: #E3E3E7;
  --border-color: #dee2e6;
  --gradient-primary: linear-gradient(90deg, #b43b25, #b45426, #ac6c29, #ad7b2b);
}

body, .bg-gray-100 {
  background-color: #E3E3E7 !important;
}

/* Helper Classes */
.text-brown {
  color: #8B4513 !important;
}

/* Gradient cho chữ */
.gradient-text {
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  color: transparent;
}

/* Scrollbar đẹp cho khu vực cuộn */
.template-scroll-area {
  max-height: 700px;
  overflow-y: auto;
  padding-right: 10px;
}

.template-scroll-area::-webkit-scrollbar {
  width: 6px;
}

.template-scroll-area::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 4px;
}

.template-scroll-area::-webkit-scrollbar-thumb {
  background: #ccc;
  border-radius: 4px;
}

/* =========================================
   2. BUTTONS & NAVIGATION
   ========================================= */
/* Gradient Button */
.btn-gradient {
  background: var(--gradient-primary);
  color: white;
  border: none;
  border-radius: 0.5rem;
  transition: all 0.3s ease;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.btn-gradient:hover {
  opacity: 0.9;
  transform: scale(1.01);
  color: white;
}

/* Navigation */
.custom-navbar {
  padding: 20px;
}

.nav-link.active {
  color: var(--color-brown) !important;
  /* Dùng màu nâu theo setting gốc của bạn */
  font-weight: 600;
}

.nav-link.active .icon {
  border-color: var(--color-brown) !important;
  /* Màu viền cam (ví dụ: màu cam của theme) */
  color: #fff !important;
  /* Màu icon cam */
  background-color: #fff !important;
  /* Đảm bảo nền vẫn là trắng */
}

/* Style chung cho khung icon để có viền */
.icon-shape {
  border: 2px solid transparent;
  /* Viền trong suốt mặc định */
  transition: all 0.3s ease;
  /* Hiệu ứng chuyển màu mượt mà */
}

/* Style cho menu con khi active (giữ nguyên màu chữ cam) */
.nav-link.active .sidenav-normal {
  color: var(--color-brown) !important;
  font-weight: bold;
}

.nav-link:hover {
  color: var(--color-brown) !important;
}

/* =========================================
   3. FORMS & INPUTS
   ========================================= */
/* Custom Select */
.custom-select {
  border-radius: 12px;
  padding: 10px 16px;
  border: 1px solid #ccc;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
  font-size: 16px;
  color: #333;
  background-color: #fff;
  transition: border-color 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
}

.custom-select:focus {
  border-color: var(--color-brown);
  box-shadow: 0 0 0 4px rgba(139, 69, 19, 0.2);
  outline: none;
}

.custom-select-wrapper {
  width: auto;
  min-width: 300px;
  margin: 20px 20px;
}

/* Dropdown Multi */
.dropdown-multi {
  position: relative;
  display: inline-block;
  width: 100%;
}

.dropdown-btn {
  text-align: left;
  padding-left: 10px;
  background: #fff;
  border: 1px solid #ccc;
  cursor: pointer;
}

.dropdown-content {
  display: none;
  position: absolute;
  background: white;
  border: 1px solid #ccc;
  padding: 10px;
  width: 100%;
  z-index: 10;
}

.dropdown-content label {
  display: block;
  cursor: pointer;
}

.dropdown-multi.show .dropdown-content {
  display: block;
}

/* Select2 Custom (Style giống Bootstrap 5) */
.select2-container .select2-selection--single {
  height: 50px !important;
  border: 1px solid var(--border-color) !important;
  border-radius: 0.375rem !important;
  display: flex;
  align-items: center;
  background-color: var(--bg-gray-light) !important;
}

.select2-container--default .select2-selection--single .select2-selection__rendered {
  line-height: 50px !important;
  padding-left: 15px !important;
  color: #212529 !important;
  font-weight: 500;
}

.select2-container--default .select2-selection--single .select2-selection__arrow {
  height: 48px !important;
  right: 10px !important;
}

/* =========================================
   4. SELECTION CARDS (Radio, Checkbox, Files)
   ========================================= */

/* --- A. RADIO SELECTION (Màu cam) --- */
.selector-item {
  margin-bottom: 20px;
  position: relative;
}

.selector-item-radio {
  position: absolute;
  opacity: 0;
  cursor: pointer;
  width: 0;
  height: 0;
}

.selector-item-label {
  display: flex;
  align-items: center;
  padding: 15px;
  background-color: #fff;
  border: 2px solid #e9ecef;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
}

.selector-item-label:hover {
  background-color: #fff8f5;
  border-color: #fed0b3;
  transform: translateY(-1px);
}

/* Active State */
.selector-item-radio:checked+.selector-item-label {
  background-color: #fff3cd;
  border-color: var(--color-orange);
  box-shadow: 0 4px 12px rgba(253, 126, 20, 0.2);
}

/* Icons & Text */
.selector-icon {
  font-size: 2rem;
  color: #adb5bd;
  margin-right: 15px;
  transition: color 0.2s ease;
  line-height: 1;
}

.selector-item-radio:checked+.selector-item-label .selector-icon {
  color: var(--color-orange);
}

.selector-content {
  display: flex;
  flex-direction: column;
}

.selector-title {
  font-weight: 700;
  font-size: 1rem;
  color: #343a40;
  margin-bottom: 2px;
}

.selector-desc {
  font-size: 0.85rem;
  color: #6c757d;
}

/* --- B. CHECKBOX CARDS (Giao diện chọn bìa) --- */
.checkbox-card-input {
  position: absolute;
  opacity: 0;
  cursor: pointer;
}

.checkbox-card-label {
  display: flex;
  align-items: center;
  padding: 15px;
  min-height: 70px;
  background-color: #fff;
  border: 2px solid #e9ecef;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
}

.checkbox-card-label:hover {
  background-color: #fff8f5;
  border-color: #fed0b3;
  transform: translateY(-1px);
}

/* Checked State */
.checkbox-card-input:checked+.checkbox-card-label {
  background-color: #fcf2ec;
  border-color: var(--color-orange-active);
  box-shadow: 0 4px 10px rgba(249, 115, 30, 0.15);
}

.checkbox-card-label i {
  font-size: 2rem !important;
  color: #adb5bd;
  transition: color 0.2s ease;
}

.checkbox-card-input:checked+.checkbox-card-label i {
  color: var(--color-orange-active) !important;
}

.checkbox-card-label .fw-bold {
  font-size: 1rem;
  color: #343a40;
}

.checkbox-card-label .small {
  font-size: 0.85rem;
  color: #6c757d;
}

/* --- Common: Check Indicator (Dấu tích V) --- */
.check-indicator {
  display: none;
  position: absolute;
  top: 10px;
  /* Điều chỉnh cho phù hợp layout */
  right: 10px;
  color: var(--color-orange);
  font-size: 1.2rem;
}

/* Radio hiện tích */
.selector-item-radio:checked+.selector-item-label .check-indicator {
  display: block;
  top: 23px;
}

/* Checkbox hiện tích */
.checkbox-card-input:checked+.checkbox-card-label .check-indicator {
  display: block;
  top: 23px;
  /* Căn chỉnh riêng cho checkbox card */
}

/* --- C. FILE SELECTOR (Word/PDF) --- */
.file-selector-input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.file-selector-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background-color: #fff;
  border: 2px solid #e9ecef;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  height: 100%;
  position: relative;
}

.file-selector-label:hover {
  border-color: var(--border-color);
  background-color: var(--bg-gray-light);
  transform: translateY(-2px);
}

.file-icon {
  font-size: 3rem;
  margin-bottom: 10px;
}

/* Word Active */
.file-selector-input[value="word"]:checked+.file-selector-label {
  border-color: #0d6efd;
  background-color: #f0f7ff;
  box-shadow: 0 4px 12px rgba(13, 110, 253, 0.2);
}

/* PDF Active */
.file-selector-input[value="pdf"]:checked+.file-selector-label {
  border-color: #dc3545;
  background-color: #fff5f5;
  box-shadow: 0 4px 12px rgba(220, 53, 69, 0.2);
}

/* Icon Circle Wrapper */
.icon-circle-wrapper {
  width: 90px;
  height: 90px;
  background-color: #f1f3f5;
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 0 auto 20px;
  color: var(--color-orange);
}

.icon-circle-wrapper i {
  font-size: 2.5rem;
  line-height: 1;
}

/* =========================================
   5. UPLOAD ZONE & TEMPLATES
   ========================================= */
.upload-zone {
  position: relative;
  border: 2px dashed var(--border-color);
  border-radius: 12px;
  background-color: var(--bg-gray-light);
  transition: all 0.3s ease;
  text-align: center;
  overflow: hidden;
  cursor: pointer;
}

.upload-zone:hover {
  border-color: var(--color-orange);
  /* Đổi màu cam khi hover */
  background-color: #fff8f5;
}

.upload-input-file {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  z-index: 10;
}

/* Template Image Cards */
.template-card {
  border: none;
  background: transparent;
  transition: transform 0.3s ease;
}

.template-img {
  width: 100%;
  height: auto;
  display: block;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
  border-radius: 8px;
  transition: all 0.3s ease;
}

.template-card:hover .template-img {
  transform: translateY(-5px);
  box-shadow: 0 15px 30px rgba(0, 0, 0, 0.2);
}

/* =========================================
   6. PROGRESS, TIMELINE & TABLE
   ========================================= */
/* Progress Bar */
#progressContainer {
  height: 22px !important;
  border-radius: 10px;
  background: #e9ecef;
}

#progressBar {
  height: 22px !important;
  font-size: 14px;
  font-weight: bold;
  line-height: 22px;
  border-radius: 10px;
}

/* Modern Timeline */
.timeline-modern {
  position: relative;
  padding-left: 1rem;
  border-left: 2px solid #e9ecef;
  margin-left: 10px;
}

.timeline-item {
  position: relative;
  margin-bottom: 1.5rem;
  padding-left: 1.5rem;
}

.timeline-marker {
  position: absolute;
  left: -21px;
  top: 0;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid #e9ecef;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
}

.timeline-marker.completed {
  background-color: #d1e7dd;
  border-color: #198754;
  color: #198754;
}

.timeline-marker.pending {
  background-color: #fff3cd;
  border-color: #ffc107;
  color: #ffc107;
}

/* Tables & Lists */
.table-hover tbody tr:hover {
  background-color: var(--bg-gray-light);
}

.table thead th {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background-color: var(--bg-gray-light);
  border-bottom: 2px solid #e9ecef;
}

.check-list-item {
  display: flex;
  align-items: flex-start;
  padding: 10px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.check-list-item:last-child {
  border-bottom: none;
}

.check-list-icon {
  flex-shrink: 0;
  margin-right: 12px;
  margin-top: 3px;
}

.stats-card {
  transition: transform 0.2s;
}

.stats-card:hover {
  transform: translateY(-2px);
}

/* =========================================
   7. DASHBOARD LAYOUT (Fixed Header/Footer)
   ========================================= */
/* Navbar Cố định */
.navbar-fixed-top {
  position: fixed;
  top: 0;
  right: 0;
  left: 17.125rem;
  /* Căn trái tránh Sidebar Soft UI */
  z-index: 1030;
  background-color: none !important;
  backdrop-filter: saturate(200%) blur(30px);
  box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.05);
  transition: all 0.2s ease-in-out;
}

/* Footer Cố định */
.footer-fixed-bottom {
  position: fixed;
  bottom: 0;
  right: 0;
  left: 17.125rem;
  z-index: 1030;
  /* background-color: #F4F4F5; */
  background-color: none;
  padding: 0.5rem 0;
  transition: all 0.2s ease-in-out;
  backdrop-filter: saturate(200%) blur(30px);
}

/* Padding cho Main Content */
.main-content {
  padding-top: 0 !important;
  margin-top: 0 !important;
  padding-bottom: 70px !important;
  min-height: 100vh;
  overflow-y: auto;
  position: relative;
  top: 0 !important;
}

/* Force specific gap for container inside main-content to align with sidebar */
.main-content > .container-fluid:first-child,
.main-content > div:first-child {
  padding-top: 1.25rem !important;
  margin-top: 0 !important;
}

/* Nuclear reset for Body and Sidenav-show state */
body.g-sidenav-show,
body.g-sidenav-show .main-content {
    padding-top: 0 !important;
    margin-top: 0 !important;
}

/* Responsive cho màn hình nhỏ */
@media (max-width: 1199.98px) {

  .navbar-fixed-top,
  .footer-fixed-bottom {
    left: 0;
  }
}

/* --- CẤU HÌNH SIDEBAR RỘNG (GHI ĐÈ MẶC ĐỊNH) --- */
.sidenav.navbar-vertical.navbar-expand-xs.fixed-start {
    width: 320px !important;
    max-width: 320px !important;
    z-index: 1050;
    /* Đảm bảo nằm trên mọi thứ */
}

/* --- ĐẨY NỘI DUNG CHÍNH SANG PHẢI --- */
/* Áp dụng cho màn hình lớn (Laptop/PC) */
@media (min-width: 1200px) {
    .g-sidenav-show .main-content {
        margin-left: 320px !important;
        margin-top: 0 !important;
        padding-top: 0 !important;
        position: relative;
        top: 0 !important;
        /* Sidebar 320px sát mép trái, không gutter */
        transition: margin-left 0.3s ease;
    }
    
    /* Global reset for all pages inside Layout */
    .main-content > .container-fluid,
    .main-content > div.container-fluid {
        padding-top: 0 !important;
        margin-top: 0 !important;
    }

    /* Đẩy Header và Footer theo */
    .navbar-fixed-top,
    .footer-fixed-bottom {
        left: 20rem !important;
        /* 320px sidebar */
        width: auto !important;
        right: 1.5rem !important;
    }
}

/* --- RESPONSIVE: MÀN HÌNH NHỎ (MOBILE/TABLET) --- */
@media (max-width: 1199.98px) {

    /* Trả về mặc định hoặc ẩn sidebar */
    .sidenav.navbar-vertical.navbar-expand-xs.fixed-start {
        transform: translateX(-340px);
        /* Ẩn sang trái (320px + enough buffer) */
        width: 320px !important;
    }

    .g-sidenav-show .main-content {
        margin-left: 0 !important;
    }

    /* Khi bấm nút mở menu (class g-sidenav-pinned được JS thêm vào body) */
    .g-sidenav-pinned .sidenav {
        transform: translateX(0) !important;
    }
}

/* --- CSS CHO MŨI TÊN COLLAPSE (Sử dụng Bootstrap Icons) --- */

.sidenav .nav-link[data-bs-toggle="collapse"] {
  position: relative;
  /* Để định vị mũi tên tuyệt đối theo thẻ a */
}

/* 1. Tạo mũi tên (Dùng mã Unicode của Bootstrap Icons) */
.sidenav .nav-link[data-bs-toggle="collapse"]::after {
  content: "\F282";
  /* Mã icon: bi-chevron-down */
  font-family: "bootstrap-icons" !important;
  /* Bắt buộc dùng font này */
  font-style: normal;
  font-weight: normal !important;
  font-variant: normal;
  text-transform: none;
  line-height: 1;
  -webkit-font-smoothing: antialiased;

  /* Vị trí */
  position: absolute;
  right: 1.5rem;
  top: 50%;
  transform: translateY(-50%);
  transition: transform 0.3s ease;

  /* Màu sắc */
  color: #adb5bd;
  font-size: 0.85rem;
}

/* 2. Khi menu mở ra (aria-expanded="true") -> Xoay mũi tên 180 độ */
.sidenav .nav-link[data-bs-toggle="collapse"][aria-expanded="true"]::after {
  transform: translateY(-50%) rotate(180deg);
  color: #344767;
  /* Đổi màu đậm hơn */
}

/* Đảm bảo Select và Button có cùng độ cao cơ sở */
#diagram-form .form-select {
  height: 41px !important;
}

#diagram-form .btn {
  height: 41px !important;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  /* Khử padding để tránh lệch font */
}

/* Khử khoảng cách mặc định của row nếu cần */
#diagram-form .row.align-items-end {
  --bs-gutter-y: 0;
}