/**
 * RESPONSIVE FIX - Giải quyết tràn trang trên màn hình 1024px
 * Thêm file này vào sau gradient-styles.css hoặc thêm trực tiếp vào header.php
 */

/* ==========================================
   FIX NAVBAR DROPDOWN - PRIORITY
   ========================================== */

/* Đảm bảo navbar không bị overflow hidden */
.navbar,
.navbar-collapse,
.navbar .container-fluid {
  overflow: visible !important;
}

.navbar.fixed-top {
  overflow: visible !important;
}

/* Dropdown menu phải hiển thị bên ngoài navbar */
.dropdown-menu {
  position: absolute !important;
  z-index: 1050 !important;
  display: none;
}

.dropdown-menu.show {
  display: block !important;
}

/* Nav item dropdown */
.nav-item.dropdown {
  position: relative !important;
}

/* Dropdown menu căn phải */
.navbar .dropdown-menu {
  position: absolute !important;
  top: 100% !important;
  left: auto !important;
  right: 0 !important;
}

.dropdown-menu-end {
  right: 0 !important;
  left: auto !important;
}

/* Responsive dropdown trên mobile */
@media (max-width: 991px) {
  .navbar-collapse {
    overflow: visible !important;
  }
  
  .navbar .dropdown-menu {
    position: static !important;
    float: none !important;
    width: 100% !important;
  }
}

@media (min-width: 992px) {
  .navbar .dropdown-menu {
    min-width: 200px !important;
    max-width: 300px !important;
  }
}

/* Z-index layers */
.navbar {
  z-index: 1030 !important;
}

.dropdown-menu {
  z-index: 1050 !important;
}

/* ==========================================
   CRITICAL FIX: OVERRIDE BOOTSTRAP CONTAINER
   ========================================== */

/* Fix Bootstrap container breakpoints - ƯU TIÊN CAO NHẤT */
@media (max-width: 1399px) {
  .container {
    max-width: 100% !important;
    width: 100% !important;
    padding-left: 15px !important;
    padding-right: 15px !important;
  }
}

@media (max-width: 1199px) {
  .container {
    max-width: 100% !important;
    width: 100% !important;
    padding-left: 12px !important;
    padding-right: 12px !important;
  }
}

@media (max-width: 991px) {
  .container {
    max-width: 100% !important;
    width: 100% !important;
    padding-left: 10px !important;
    padding-right: 10px !important;
  }
}

/* ==========================================
   LEVEL 1: NGĂN TRÀN TOÀN BỘ TRANG
   ========================================== */

html {
  overflow-x: hidden !important;
  max-width: 100vw !important;
  width: 100% !important;
}

body {
  overflow-x: hidden !important;
  max-width: 100vw !important;
  width: 100% !important;
  margin: 0 !important;
  padding: 0 !important;
}

/* ==========================================
   LEVEL 2: FIX TẤT CẢ CONTAINERS
   ========================================== */

/* Bootstrap containers */
.container,
.container-fluid,
.container-sm,
.container-md,
.container-lg,
.container-xl,
.container-xxl {
  max-width: 100% !important;
  overflow-x: hidden !important;
}

/* Bootstrap rows - Reset margin âm */
.row {
  margin-left: 0 !important;
  margin-right: 0 !important;
  max-width: 100% !important;
}

/* Bootstrap columns */
[class*="col-"],
.col {
  max-width: 100% !important;
}

/* ==========================================
   LEVEL 3: FIX CÁC SECTIONS CHÍNH
   ========================================== */

/* Main content wrapper */
.main-content {
  max-width: 100% !important;
  width: 100% !important;
  overflow-x: hidden !important;
  padding-left: 15px !important;
  padding-right: 15px !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
}

/* Step 1 và Step 2 */
.step1,
.step2 {
  max-width: 100% !important;
  width: 100% !important;
  overflow-x: hidden !important;
  padding-left: 15px !important;
  padding-right: 15px !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
}

/* Flex containers */
.d-flex,
.d-flex.flex-wrap,
.d-flex.flex-wrap.gap-2 {
  max-width: 100% !important;
  width: 100% !important;
  overflow-x: hidden !important;
  padding-left: 15px !important;
  padding-right: 15px !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
}

/* Tags section */
.tags,
.tags .d-flex {
  max-width: 100% !important;
  width: 100% !important;
  overflow-x: hidden !important;
  padding-left: 15px !important;
  padding-right: 15px !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
}

/* ==========================================
   LEVEL 4: FIX CÁC PHẦN TỬ BOOTSTRAP 5
   ========================================== */

/* Cards */
.card,
.card-body,
.card-header,
.card-footer {
  max-width: 100% !important;
  overflow: visible !important;
}

.card.border-0 {
  overflow: visible !important;
}

/* Tables */
.table-responsive {
  max-width: 100% !important;
  overflow-x: auto !important;
}

table {
  max-width: 100% !important;
}

/* Tab content */
.tab-content {
  overflow: visible !important;
}

/* Forms */
.form-control,
.form-select,
textarea,
input[type="text"],
input[type="email"],
input[type="password"] {
  max-width: 100% !important;
  width: 100% !important;
}

/* Buttons */
/*.btn,
button {
  max-width: 100% !important;
}*/

.btn-block,
.d-grid .btn {
  width: 100% !important;
}

/* Alerts */
.alert {
  max-width: 100% !important;
}

/* Modals */
.modal-dialog {
  max-width: calc(100vw - 30px) !important;
  margin: 15px auto !important;
}

/* ==========================================
   LEVEL 5: FIX NAV TABS
   ========================================== */

/* Nav tabs container - CHO PHÉP WRAP */
.nav-tabs {
  max-width: 100% !important;
  overflow-x: visible !important;
  overflow-y: visible !important;
  flex-wrap: wrap !important;
}

/* Hide scrollbar */
.nav-tabs::-webkit-scrollbar {
  display: none !important;
}

/* Nav items - cho phép wrap */
.nav-tabs .nav-item {
  flex-shrink: 1 !important;
  max-width: none !important;
  margin-bottom: 8px !important;
  margin-right: 8px !important;
}

.nav-tabs .nav-item:last-child {
  margin-right: 0 !important;
}

/* Nav links - cho phép text wrap */
.nav-tabs .nav-link {
  white-space: normal !important;
  max-width: none !important;
  word-wrap: break-word !important;
}

/* ==========================================
   LEVEL 6: FIX CÁC PHẦN TỬ CUSTOM
   ========================================== */

/* Progress bars */
.progress {
  max-width: 100% !important;
}

/* Images */
img {
  max-width: 100% !important;
  height: auto !important;
}

/* Textarea mlink */
.mlink,
textarea.mlink {
  max-width: 100% !important;
  width: 100% !important;
}

/* List links */
.listlink,
.listurl {
  max-width: 100% !important;
  width: 100% !important;
}

/* Search form */
.search-form,
.search-form .form-control {
  max-width: 100% !important;
}

/* ==========================================
   RESPONSIVE: MÀN HÌNH <= 1024px
   ========================================== */

@media (max-width: 1024px) {
  /* Giảm padding để tiết kiệm không gian */
  body {
    padding: 0 !important;
  }
  
  .container,
  .container-fluid {
    padding-left: 10px !important;
    padding-right: 10px !important;
  }
  
  .main-content,
  .step1,
  .step2,
  .d-flex,
  .tags {
    padding-left: 10px !important;
    padding-right: 10px !important;
  }
  
  /* Nav tabs - cho phép wrap trên mobile */
 /* .nav-tabs {
    flex-wrap: wrap !important;
  }*/
  
/*  .nav-tabs .nav-link {
    font-size: 0.5rem !important;
    padding: 6px 10px !important;
  }*/
  
  /* Download button */
  .btn-download {
    font-size: 1.1rem !important;
    padding: 15px 25px !important;
  }
  
  /* Card trong tab */
  .card.border-0 {
    margin-left: -10px !important;
    margin-right: -10px !important;
  }
  
  /* Tab content */
  .tab-content {
    padding: 10px !important;
  }
}

/* ==========================================
   RESPONSIVE: MÀN HÌNH <= 768px (TABLET)
   ========================================== */

@media (max-width: 768px) {
  .container,
  .container-fluid,
  .main-content,
  .step1,
  .step2 {
    padding-left: 5px !important;
    padding-right: 5px !important;
  }
  
  .nav-tabs .nav-link {
    font-size: 0.7rem !important;
    padding: 5px 8px !important;
  }
}

/* ==========================================
   FIX ĐẶC BIỆT: FIELDSET VÀ FORM
   ========================================== */

fieldset {
  max-width: 100% !important;
  overflow-x: hidden !important;
  padding-left: 10px !important;
  padding-right: 10px !important;
}

form {
  max-width: 100% !important;
  overflow-x: hidden !important;
}

/* ==========================================
   VŨ LỰC: BẮT BUỘC MỌI THỨ PHẢI FIT
   ========================================== */

/* Apply cho mọi phần tử */
* {
  box-sizing: border-box !important;
}

/* Ngăn bất kỳ phần tử nào vượt quá viewport */
body * {
  max-width: 100vw !important;
}

/* ==========================================
   DEBUG MODE (Bỏ comment để bật)
   ========================================== */

/*
@media (max-width: 1024px) {
  * {
    outline: 1px solid rgba(255, 0, 0, 0.1) !important;
  }
  
  body > * {
    outline: 2px solid rgba(255, 0, 0, 0.3) !important;
  }
  
  .step1,
  .step2,
  .main-content {
    outline: 3px solid red !important;
  }
}
*/

   /**
 * RESPONSIVE FIX - Giải quyết tràn trang trên màn hình 1024px
 * Thêm file này vào sau gradient-styles.css hoặc thêm trực tiếp vào header.php
 */

/* ==========================================
   FIX NAVBAR DROPDOWN - PRIORITY
   ========================================== */

/* Đảm bảo navbar không bị overflow hidden */
.navbar,
.navbar-collapse,
.navbar .container-fluid {
  overflow: visible !important;
}

.navbar.fixed-top {
  overflow: visible !important;
}

/* Dropdown menu phải hiển thị bên ngoài navbar */
.dropdown-menu {
  position: absolute !important;
  z-index: 1050 !important;
  display: none;
}

.dropdown-menu.show {
  display: block !important;
}

/* Nav item dropdown */
.nav-item.dropdown {
  position: relative !important;
}

/* Dropdown menu căn phải */
.navbar .dropdown-menu {
  position: absolute !important;
  top: 100% !important;
  left: auto !important;
  right: 0 !important;
}

.dropdown-menu-end {
  right: 0 !important;
  left: auto !important;
}

/* Responsive dropdown trên mobile */
@media (max-width: 991px) {
  .navbar-collapse {
    overflow: visible !important;
  }
  
  .navbar .dropdown-menu {
    position: static !important;
    float: none !important;
    width: 100% !important;
  }
}

@media (min-width: 992px) {
  .navbar .dropdown-menu {
    min-width: 200px !important;
    max-width: 300px !important;
  }
}

/* Z-index layers */
.navbar {
  z-index: 1030 !important;
}

.dropdown-menu {
  z-index: 1050 !important;
}

/* ==========================================
   CRITICAL FIX: OVERRIDE BOOTSTRAP CONTAINER
   ========================================== */

/* Fix Bootstrap container breakpoints - ƯU TIÊN CAO NHẤT */
@media (max-width: 1399px) {
  .container {
    max-width: 100% !important;
    width: 100% !important;
    padding-left: 15px !important;
    padding-right: 15px !important;
  }
}

@media (max-width: 1199px) {
  .container {
    max-width: 100% !important;
    width: 100% !important;
    padding-left: 12px !important;
    padding-right: 12px !important;
  }
}

@media (max-width: 991px) {
  .container {
    max-width: 100% !important;
    width: 100% !important;
    padding-left: 10px !important;
    padding-right: 10px !important;
  }
}

/* ==========================================
   LEVEL 1: NGĂN TRÀN TOÀN BỘ TRANG
   ========================================== */

html {
  overflow-x: hidden !important;
  max-width: 100vw !important;
  width: 100% !important;
}

body {
  overflow-x: hidden !important;
  max-width: 100vw !important;
  width: 100% !important;
  margin: 0 !important;
  padding: 0 !important;
}

/* ==========================================
   LEVEL 2: FIX TẤT CẢ CONTAINERS
   ========================================== */

/* Bootstrap containers */
.container,
.container-fluid,
.container-sm,
.container-md,
.container-lg,
.container-xl,
.container-xxl {
  max-width: 100% !important;
  overflow-x: hidden !important;
}

/* Bootstrap rows - Reset margin âm */
.row {
  margin-left: 0 !important;
  margin-right: 0 !important;
  max-width: 100% !important;
  padding-left: 0 !important;
  padding-right: 0 !important;
}

/* Bootstrap columns - Padding đều nhau */
[class*="col-"],
.col {
  max-width: 100% !important;
  padding-left: 15px !important;
  padding-right: 15px !important;
}

/* Tất cả phần tử con trực tiếp của row có padding đều */
.row > * {
  padding-left: 15px !important;
  padding-right: 15px !important;
}

/* Giảm padding trên màn hình nhỏ */
@media (max-width: 768px) {
  .row > [class*="col-"],
  .row > .col,
  .row > * {
    padding-left: 10px !important;
    padding-right: 10px !important;
  }
}

@media (max-width: 576px) {
  .row > [class*="col-"],
  .row > .col,
  .row > * {
    padding-left: 8px !important;
    padding-right: 8px !important;
  }
}

/* ==========================================
   LEVEL 3: FIX CÁC SECTIONS CHÍNH
   ========================================== */

/* Main content wrapper */
.main-content {
  max-width: 100% !important;
  width: 100% !important;
  overflow-x: hidden !important;
  padding-left: 15px !important;
  padding-right: 15px !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
}

/* Step 1 và Step 2 */
.step1,
.step2 {
  max-width: 100% !important;
  width: 100% !important;
  overflow-x: hidden !important;
  padding-left: 15px !important;
  padding-right: 15px !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
}

/* CĂN LỀ THẲNG HÀNG CHO TẤT CẢ PHẦN TỬ TRONG STEP1 */
.step1 > * {
  margin-left: 0 !important;
  margin-right: 0 !important;
}

.step1 .row {
  margin-left: 0 !important;
  margin-right: 0 !important;
}

.step1 .row > [class*="col-"],
.step1 .row > .col,
.step1 .col-md-12 {
  padding-left: 15px !important;
  padding-right: 15px !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
}

.step1 .alert,
.step1 .card,
.step1 .nav-tabs,
.step1 .tab-content,
.step1 fieldset,
.step1 .form-control,
.step1 .d-grid {
  margin-left: 0 !important;
  margin-right: 0 !important;
  width: 100% !important;
}

/*.step1 .card-body {
  padding-left: 15px !important;
  padding-right: 15px !important;
}*/

.step1 .tab-pane {
  padding-left: 0 !important;
  padding-right: 0 !important;
}

@media (max-width: 768px) {
  .step1,
  .step2 {
    padding-left: 10px !important;
    padding-right: 10px !important;
  }
  
  .step1 .row > [class*="col-"],
  .step1 .row > .col,
  .step1 .col-md-12 {
    padding-left: 10px !important;
    padding-right: 10px !important;
  }
  
  .tab-content.p-4 {
    padding-left: 0px !important;
    padding-right: 0px !important;
  }
}

@media (max-width: 576px) {
  .step1,
  .step2 {
    padding-left: 8px !important;
    padding-right: 8px !important;
  }
  
  .step1 .row > [class*="col-"],
  .step1 .row > .col,
  .step1 .col-md-12 {
    padding-left: 8px !important;
    padding-right: 8px !important;
  }
  
  .step1 .card-body {
    padding-left: 8px !important;
    padding-right: 8px !important;
  }
}

/* Flex containers */
.d-flex,
.d-flex.flex-wrap,
.d-flex.flex-wrap.gap-2 {
  max-width: 100% !important;
  width: 100% !important;
  overflow-x: hidden !important;
  padding-left: 15px !important;
  padding-right: 15px !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
}

/* Tags section */
.tags,
.tags .d-flex {
  max-width: 100% !important;
  width: 100% !important;
  overflow-x: hidden !important;
  padding-left: 15px !important;
  padding-right: 15px !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
}

/* ==========================================
   LEVEL 4: FIX CÁC PHẦN TỬ BOOTSTRAP 5
   ========================================== */

/* Cards */
.card,
.card-body,
.card-header,
.card-footer {
  max-width: 100% !important;
  overflow: visible !important;
}

.card.border-0 {
  overflow: visible !important;
}

/* Card trong row có margin đều */
.row .card {
  margin-left: 0 !important;
  margin-right: 0 !important;
}

/* Card body có padding đều */
/*.card-body {
  padding: 15px !important;
}*/

@media (max-width: 768px) {
  .card-body {
    padding: 10px !important;
  }
}

/* Tables */
.table-responsive {
  max-width: 100% !important;
  overflow-x: auto !important;
}

table {
  max-width: 100% !important;
}

/* Tab content */
.tab-content {
  overflow: visible !important;
}

/* Forms */
.form-control,
.form-select,
textarea,
input[type="text"],
input[type="email"],
input[type="password"] {
  max-width: 100% !important;
  width: 100% !important;
}

/* Giảm chiều cao textarea mlink xuống 100px */
textarea.mlink,
.form-control.mlink {
  height: 100px !important;
  min-height: 100px !important;
  max-height: 200px !important;
}

/* Buttons */
.btn,
button {
  max-width: 100% !important;
}

.btn-block,
.d-grid .btn {
  width: 100% !important;
}

/* Alerts */
.alert {
  max-width: 100% !important;
}

/* Modals */
.modal-dialog {
  max-width: calc(100vw - 30px) !important;
  margin: 15px auto !important;
}

/* ==========================================
   LEVEL 5: FIX NAV TABS
   ========================================== */

/* Nav tabs container - CHO PHÉP WRAP */
.nav-tabs {
  max-width: 100% !important;
  overflow-x: visible !important;
  overflow-y: visible !important;
  flex-wrap: wrap !important;
}

/* Hide scrollbar */
.nav-tabs::-webkit-scrollbar {
  display: none !important;
}

/* Nav items - cho phép wrap */
.nav-tabs .nav-item {
  flex-shrink: 1 !important;
  max-width: none !important;
  margin-bottom: 8px !important;
  margin-right: 8px !important;
}

.nav-tabs .nav-item:last-child {
  margin-right: 0 !important;
}

/* Nav links - cho phép text wrap */
.nav-tabs .nav-link {
  white-space: normal !important;
  max-width: none !important;
  word-wrap: break-word !important;
}

/* ==========================================
   LEVEL 6: FIX CÁC PHẦN TỬ CUSTOM
   ========================================== */

/* Progress bars */
.progress {
  max-width: 100% !important;
}

/* Images */
img {
  max-width: 100% !important;
  height: auto !important;
}

/* Textarea mlink */
.mlink,
textarea.mlink {
  max-width: 100% !important;
  width: 100% !important;
}

/* List links */
.listlink,
.listurl {
  max-width: 100% !important;
  width: 100% !important;
}

/* Search form */
.search-form,
.search-form .form-control {
  max-width: 100% !important;
}

/* ==========================================
   RESPONSIVE: MÀN HÌNH <= 1024px
   ========================================== */

@media (max-width: 1024px) {
  /* Giảm padding để tiết kiệm không gian */
  body {
    padding: 0 !important;
  }
  
  .container,
  .container-fluid {
    padding-left: 10px !important;
    padding-right: 10px !important;
  }
  
  .main-content,
  .step1,
  .step2,
  .d-flex,
  .tags {
    padding-left: 10px !important;
    padding-right: 10px !important;
  }
  
  /* Nav tabs - cho phép wrap trên mobile */
  .nav-tabs {
    flex-wrap: wrap !important;
  }
  
  .nav-tabs .nav-link {
    font-size: 0.75rem !important;
    padding: 6px 10px !important;
  }
  
  /* Download button */
  .btn-download {
    font-size: 1.1rem !important;
    padding: 15px 25px !important;
  }
  
  /* Card trong tab */
  .card.border-0 {
    margin-left: -10px !important;
    margin-right: -10px !important;
  }
  
  /* Tab content */
  .tab-content {
    padding: 0px !important;
  }

}

/* ==========================================
   RESPONSIVE: MÀN HÌNH <= 768px (TABLET)
   ========================================== */

@media (max-width: 768px) {
  .container,
  .container-fluid,
  .main-content,
  .step1,
  .step2 {
    padding-left: 5px !important;
    padding-right: 5px !important;
  }
  
  .nav-tabs .nav-link {
    font-size: 0.7rem !important;
    padding: 5px 8px !important;
  }
}

/* ==========================================
   FIX ĐẶC BIỆT: FIELDSET VÀ FORM
   ========================================== */

fieldset {
  max-width: 100% !important;
  overflow-x: hidden !important;
  padding-left: 0px !important;
  padding-right: 0px !important;
}

form {
  max-width: 100% !important;
  overflow-x: hidden !important;
}

/* ==========================================
   VŨ LỰC: BẮT BUỘC MỌI THỨ PHẢI FIT
   ========================================== */

/* Apply cho mọi phần tử */
* {
  box-sizing: border-box !important;
}

/* Ngăn bất kỳ phần tử nào vượt quá viewport */
body * {
  max-width: 100vw !important;
}

/* ==========================================
   DEBUG MODE (Bỏ comment để bật)
   ========================================== */

/*
@media (max-width: 1024px) {
  * {
    outline: 1px solid rgba(255, 0, 0, 0.1) !important;
  }
  
  body > * {
    outline: 2px solid rgba(255, 0, 0, 0.3) !important;
  }
  
  .step1,
  .step2,
  .main-content {
    outline: 3px solid red !important;
  }
}
*/

/* 3. Tab content - BỎ PADDING TRÁI PHẢI */
  .step1 .tab-content.p-4 {
    margin-left: 0 !important;
    margin-right: 0 !important;
    padding-left: 0 !important;        /* ← BỎ PADDING TRÁI */
    padding-right: 0 !important;       /* ← BỎ PADDING PHẢI */
    padding-top: 1.5rem !important;    /* Giữ padding trên (24px) */
    padding-bottom: 1.5rem !important; /* Giữ padding dưới (24px) */
    width: 100% !important;
    box-sizing: border-box !important;
    font-size: 0.7rem !important;
  }


  /* Font nhỏ và màu xám */
.tab-content.p-4 textarea {
  font-family: 'Fira Code', monospace !important;
  font-size: 0.875rem !important;    /* 14px - nhỏ hơn */
  color: #6c757d !important;          /* Màu xám nhẹ */
  font-weight: 400 !important;
}

/* Placeholder màu xám nhạt */
.tab-content.p-4 textarea::placeholder {
  color: #adb5bd !important;          /* Xám nhạt hơn */
  font-size: 0.7rem !important;
  /*font-style: italic !important;      /* Chữ nghiêng */*/
}

/* Placeholder TỰ ĐỘNG ẨN khi click */
.tab-content.p-4 textarea:focus::placeholder {
  opacity: 0 !important;              /* Ẩn hoàn toàn */
  transition: opacity 0.2s ease !important;
}

/* Text đen đậm khi có nội dung */
.tab-content.p-4 textarea:not(:placeholder-shown) {
  color: #212529 !important;          /* Đen khi gõ chữ */
}