/* ==========================================================================
   1. STYLES CHUNG & LAYOUT CƠ BẢN
   ========================================================================== */

html,
body {
  height: 100%;
}

body {
  display: flex;
  flex-direction: column;
  background-color: #f8f9fa;
}

.main-content {
  flex-grow: 1;
}

.page-title {
  white-space: nowrap;
}

.table-responsive {
  overflow-x: auto;
}

.filter-container {
  width: auto;
  min-width: 220px;
}

.filter-container .form-select {
  width: auto;
}

/* ==========================================================================
   2. BẢNG SCHEDULE TABLE
   ========================================================================== */

.schedule-table {
  table-layout: fixed;
  width: 100%;
  min-width: 1200px;
  border-collapse: collapse;
}

.schedule-table th,
.schedule-table td {
  border: 1px solid #dee2e6;
  vertical-align: top;
  text-align: left;
  padding: 0;
}

.schedule-table thead th {
  background-color: #0067C0;
  color: white;
  vertical-align: middle;
  text-align: center;
  padding: 8px;
}

.schedule-table thead .short-date {
  display: none;
}

.schedule-table thead .full-date {
  display: inline;
}

.leader-info {
  font-weight: bold;
  padding: 8px 10px;
  background-color: #e9ecef;
  width: 200px;
  vertical-align: middle;
}

.session-block {
  padding: 4px;
}

.session-block:first-child {
  border-bottom: 1px dashed #e0e0e0;
}

.session-header {
  font-weight: bold;
  color: #6c757d;
  font-size: 0.9em;
  padding: 2px;
}

.schedule-content {
  padding: 6px 8px;
  border-radius: 4px;
  font-size: 0.9em;
  text-align: left;
  white-space: pre-wrap;
  word-break: break-word;
}

.schedule-content:not(:empty).sang {
  background-color: #e7f3ff;
}

.schedule-content:not(:empty).chieu {
  background-color: #fff3cd;
}

.today {
  background-color: #fffce6;
}

/* Địa điểm & Sao quan trọng */
.schedule-location {
  font-style: italic;
  font-size: 0.8em;
  color: #6c757d;
  margin-top: 4px;
  padding-top: 2px;
  border-top: 1px dashed #e0e0e0;
  white-space: normal;
  word-break: break-word;
}

.schedule-content {
  font-size: 1.1rem !important;
  line-height: 1.4 !important;
  padding: 8px 10px !important;
  position: relative;
  white-space: normal !important;
  overflow-wrap: break-word;
  margin: 0 !important;
}

.schedule-location {
  font-style: italic;
  font-size: 0.95rem !important;
  color: #666;
  margin-top: 6px;
  padding-top: 4px;
  border-top: 1px dashed #ccc;
  white-space: normal;
}

.schedule-content.important::after {
  content: '★';
  position: absolute;
  top: 4px;
  right: 4px;
  color: #DE0C78;
  font-size: 1.3em;
  text-shadow: 0 0 2px #DE0C78;
  pointer-events: none;
  z-index: 10;
  user-select: none;
}

.important-star {
  position: absolute !important;
  top: 4px !important;
  right: 4px !important;
  color: #DE0C78 !important;
  font-size: 1.3em !important;
  text-shadow: 0 0 2px #DE0C78 !important;
  pointer-events: none !important;
  z-index: 10 !important;
  user-select: none !important;
}

.schedule-content.important {
  padding-right: 22px !important;
}

.schedule-table td {
  padding: 0 !important;
  margin: 0 !important;
  vertical-align: top;
}

.session-block {
  padding: 4px !important;
  margin: 0 !important;
}

/* ==========================================================================
   3. STYLES CHO ADMIN
   ========================================================================== */

.is-admin .schedule-cell .schedule-content:hover {
  background-color: #d0eaff;
  cursor: pointer;
}

.delete-mode .schedule-content:not(:empty) {
  cursor: pointer;
  border: 2px dashed #adb5bd;
}

.delete-mode .schedule-content.selected {
  background-color: #dc3545 !important;
  color: white !important;
  border: 2px solid #a71d2a;
}

/* Nút Thoát Admin */
body.is-admin .page-title {
  margin-top: 40px !important;
  margin-bottom: 20px !important;
  padding: 0 !important;
}

body.is-admin .container-fluid {
  margin-top: 5px !important;
  padding-top: 5px !important;
}

/* .btn-exit-admin:hover,
.btn-exit-admin:focus {
  background: #d32f2f;
  box-shadow: 0 4px 16px rgba(244, 67, 54, 0.2);
  color: #fff !important;
  text-decoration: none;
  transform: translateY(-1px);
}

.btn-exit-admin:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(244, 67, 54, 0.15);
} */

/* .btn-exit-admin,
#btn-exit-admin,
a[href*="index.php"].btn-exit-admin {
    position: absolute !important;
    top: 80px !important;
    left: 16px !important;
    z-index: 9999 !important;
    min-width: 120px !important;
    height: 70px !important;
    padding: 0 16px !important;
    font-size: 1rem !important;
    font-weight: 500 !important;
    background: #f44336 !important;
    color: #fff !important;
    border: none !important;
    border-radius: 6px !important;
    box-shadow: 0 2px 10px rgba(244, 67, 54, 0.1) !important;
    transition: all 0.2s ease !important;
    text-decoration: none !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
} */

.btn-exit-admin {
    position: absolute;
    top: 80px;
    left: 16px;
    z-index: 9999;
    min-width: 120px;
    height: 60px;
    padding: 0 16px;
    font-size: 1rem;
    font-weight: 500;
    background: #f44336;
    color: #fff !important;
    border: none;
    border-radius: 6px;
    box-shadow: 0 2px 10px rgba(244,67,54,0.1);
    transition: all 0.2s ease;
    text-decoration: none !important;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
  }

/* ==========================================================================
   4. TRANG LOGIN & CÁC THÀNH PHẦN KHÁC
   ========================================================================== */

.body-login .main-content {
  display: flex;
}

.login-form {
  width: 100%;
  max-width: 420px;
  padding: 2rem;
  background-color: #ffffff;
  border: 1px solid #dee2e6;
  border-radius: 0.5rem;
  box-shadow: 0 0.5rem 1.5rem rgba(0, 0, 0, 0.1);
  margin: auto;
}

.header-logo {
  position: absolute;
  top: 10px;
  left: 10px;
  width: 200px;
  height: auto;
  z-index: 1050;
  cursor: pointer;
  transition: opacity 0.3s ease;
}

.header-logo:hover {
  opacity: 0.8;
}

/* Hiển thị tiêu đề chung */
.page-title {
  color: #2B579A !important;
  display: block !important;
  text-align: center;
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 1rem;
}

.page-title {
  /* Ghi đè cho logo */
  margin-left: 80px !important;
  margin-top: 90px !important;
}

/* ==========================================================================
   5. RESPONSIVE - GIAO DIỆN DI ĐỘNG
   ========================================================================== */

/* --- Styles chung cho mobile (< 992px) --- */
@media screen and (max-width: 992px) {
  .d-md-none {
    display: block !important;
  }

  .d-none.d-md-flex {
    display: none !important;
  }

  .page-title {
    font-size: 1.5rem !important;
    margin-bottom: 1rem !important;
  }

  .schedule-table {
    min-width: unset;
  }

  .mobile-controls {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
  }

  .mobile-filter-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem !important;
  }

  .mobile-controls-row-2 {
    display: flex;
    align-items: center;
  }

  .is-admin.delete-mode-active .mobile-filter-row,
  .is-admin.delete-mode-active .mobile-controls-row-2 {
    display: none !important;
  }

  .is-admin.delete-mode-active .mobile-delete-controls {
    display: block !important;
  }

  .btn {
    border-radius: 0.375rem;
    transition: all 0.2s ease-in-out;
  }

  .form-select {
    border-radius: 0.375rem;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
  }

  .mobile-controls > * {
    margin-bottom: 0;
  }

  .btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  }

  .page-title {
    color: #2B579A !important;
  }

  .mobile-controls-row-2 .btn {
    min-width: 100px;
    text-align: center;
  }

  #prev-week-mobile,
  #next-week-mobile,
  #today-mobile {
    min-width: 120px !important;
    max-width: 120px;
  }

  .is-admin .mobile-controls {
    padding: 0.75rem;
    gap: 0.75rem;
  }

  .is-admin .mobile-filter-row {
    margin-bottom: 0.5rem;
  }

  .is-admin .mobile-controls-row-2 {
    margin: 0;
    padding: 0;
  }

  .header-logo {
    width: 165px;
    top: 8px;
    left: 8px;
  }

  .page-title {
    margin-left: 40px !important;
    margin-top: 80px !important;
    font-size: 1.3rem !important;
  }

  body.is-admin button#prev-week-mobile,
  body.is-admin button#next-week-mobile {
    min-width: 140px !important;
    max-width: 140px !important;
    padding: 0.375rem 1rem !important;
    font-size: 0.95rem !important;
    min-height: 40px !important;
  }
}

/* --- Chỉ cho mobile màn hình ngang (landscape < 992px) --- */
@media (orientation: landscape) and (max-width: 992px) {
  .mobile-day-header {
    display: none;
  }

  .mobile-controls-row-2 {
    justify-content: center;
  }

  .index-mobile-filter {
    justify-content: flex-start;
  }

  .index-mobile-filter #week-title-mobile {
    margin-left: auto;
  }

  body:not(.is-admin) .mobile-controls {
    margin-top: -0.75rem;
  }

  .schedule-table thead .short-date {
    display: none;
  }

  .schedule-table thead .full-date {
    display: inline;
  }

  .page-title {
    font-size: 1.1rem !important;
    margin-bottom: 1rem !important;
  }

  body:not(.is-admin) .mobile-controls {
    margin-top: -0.5rem;
  }

  .schedule-table tr {
    margin-bottom: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .mobile-date-header {
    display: none !important;
  }

  .schedule-table td.leader-info {
    background-color: #e9ecef;
    color: #000;
    padding: 8px 10px;
    font-size: 1rem;
  }

  body:not(.is-admin) .page-title {
    color: #0067C0 !important;
  }

  .mobile-controls-row-2 .btn {
    min-width: 70px;
    max-width: 70px;
  }

  .index-mobile-filter .mobile-controls-row-2 .btn {
    min-width: 70px !important;
    max-width: 70px;
  }

  .schedule-content {
    font-size: 0.95rem !important;
  }

  .schedule-location {
    font-size: 0.85rem !important;
  }

  .btn-exit-admin {
    position: absolute;
    top: 70px !important; /* Tăng từ 15px lên 40px để button xuống thấp hơn */
    left: 15px !important;
    z-index: 100;
    min-width: 120px;
    height: 60px;
    padding: 0 12px;
    font-size: 0.9rem;
    font-weight: 500;
    background: #f44336;
    color: #fff !important;
    border: none;
    border-radius: 5px;
    box-shadow: 0 2px 8px rgba(244,67,54,0.15);
    transition: all 0.2s ease;
    text-decoration: none !important;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;   
  }
  body.is-admin.page-title {
      margin-top: 20 px !important;
      margin-bottom: 6px !important;
      font-size: 1.3rem !important;
  }

  body.is-admin.page-title {
    margin-top: 20px !important;
    margin-bottom: 6px !important;
    font-size: 1.3rem !important;
  }

  .admin-mobile-controls .mobile-filter-row {
    margin-bottom: 0.3rem !important;
    padding: 0.2rem 0 !important;
  }

  .admin-mobile-controls .mobile-nav-buttons {
    justify-content: center !important;
    align-items: center;
    display: flex !important;
  }

  .admin-mobile-controls .mobile-controls-row-2 {
    gap: 1rem !important;
    align-items: center;
  }

  .admin-mobile-controls {
    gap: 0.5rem !important;
  }

  button#prev-week-mobile,
  button#next-week-mobile {
    text-indent: -9999px !important;
    overflow: hidden !important;
    position: relative !important;
    white-space: nowrap !important;
  }

  button#prev-week-mobile::after {
    content: "Tuần trước" !important;
    text-indent: 0 !important;
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 0.9rem !important;
    color: #0067C0 !important;
  }

  button#next-week-mobile::after {
    content: "Tuần sau" !important;
    text-indent: 0 !important;
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 0.9rem !important;
    color: #0067C0 !important;
  }

  body.is-admin .mobile-nav-buttons {
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    gap: 15px !important;
    width: 100% !important;
    margin: 0 auto !important;
  }

  body.is-admin button#prev-week-mobile,
  body.is-admin button#next-week-mobile {
    min-width: 120px !important;
    max-width: 120px !important;
    flex: 0 0 auto !important;
    margin: 0 !important;
  }

  body.is-admin .admin-mobile-controls .mobile-controls-row-2 {
    justify-content: center !important;
    display: flex !important;
    align-items: center !important;
  }

  button#prev-week-mobile:active,
  button#next-week-mobile:active {
    background-color: white !important;
    color: #0d6efd !important;
    border: 1px solid #0d6efd !important;
    box-shadow: none !important;
    outline: none !important;
    text-shadow: none !important;
    cursor: pointer !important;
  }

  .admin-mobile-controls {
    padding: 0.75rem 1rem;
    gap: 0.75rem;
  }

  .admin-mobile-controls .mobile-filter-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
    margin-bottom: 0.75rem;
    gap: 1rem;
  }

  .admin-mobile-controls .btn-group {
    order: 1;
    flex-shrink: 0;
  }

  .admin-mobile-controls .page-title {
    order: 2;
    flex-grow: 1;
    text-align: center;
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: #2B579A;
  }

  .admin-mobile-controls .mobile-controls-row-2 {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0;
    margin: 0;
    gap: 1rem;
  }

  .admin-mobile-controls .filter-container {
    order: 1;
    min-width: 180px;
    flex-shrink: 0;
  }

  .admin-mobile-controls .mobile-nav-buttons {
    order: 2;
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    flex-grow: 1;
  }

  .admin-mobile-controls #week-title-mobile {
    order: 3;
    font-size: 0.9rem;
    font-weight: 500;
    flex-shrink: 0;
    margin: 0;
    display: block !important;
  }

  .admin-mobile-controls .btn-group .btn {
    padding: 0.4rem 0.6rem;
    font-size: 0.8rem;
  }
}

/* --- Chỉ cho mobile màn hình dọc (portrait < 992px) --- */
@media (orientation: portrait) and (max-width: 992px) {
  .mobile-controls-row-2 {
    justify-content: center;
  }

  .index-mobile-filter {
    justify-content: space-between;
  }

  #week-title-mobile {
    display: none !important;
  }

  .table-responsive {
    overflow-x: hidden;
  }

  .schedule-table,
  .schedule-table tbody,
  .schedule-table tr,
  .schedule-table td {
    all: revert;
  }

  .schedule-table {
    border: 0;
    width: 100%;
  }

  .schedule-table thead {
    display: none;
  }

  .schedule-table tr {
    display: block;
    margin-bottom: 1rem;
    border: 1px solid #dee2e6;
    border-radius: 0.25rem;
    background-color: #fff;
  }

  .schedule-table td {
    display: block;
    width: 100% !important;
    border: none;
    border-bottom: 1px solid #f0f0f0;
    padding: 0;
  }

  .schedule-table tr > td:last-child {
    border-bottom: none;
  }

  .schedule-table td.leader-info {
    display: block;
    width: 100% !important;
    background-color: #343a40;
    color: white;
    text-align: center;
    padding: 0.5rem;
    border-bottom: 3px solid #0d6efd;
  }

  .schedule-table td.leader-info small {
    color: #adb5bd;
  }

  .mobile-day-header {
    display: block;
    font-weight: bold;
    padding: 0.5rem 0.75rem;
    background-color: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
    color: #495057;
  }

  .session-block {
    display: grid;
    grid-template-columns: 80px 1fr;
    align-items: start;
    gap: 8px;
    padding: 0.5rem 0.75rem;
    text-align: left;
  }

  .session-header {
    font-weight: bold;
    color: #495057;
    padding-top: 6px;
  }

  .schedule-content {
    text-align: left;
  }

  .mobile-date-header {
    background-color: #0d6efd;
    color: white;
    text-align: center;
    padding: 1rem;
    font-weight: bold;
    font-size: 1.1rem;
    margin-bottom: 0;
    border-radius: 0.375rem;
  }

  .schedule-table tr {
    margin-bottom: 0;
    border-radius: 0;
    overflow: hidden;
    box-shadow: none;
    border: 1px solid #dee2e6;
  }

  .schedule-table td.leader-info {
    background-color: #495057;
    color: white;
    text-align: center;
    padding: 0.5rem;
    font-size: 0.9rem;
    border-bottom: 2px solid #0d6efd;
    min-height: auto;
  }

  .session-block {
    display: grid;
    grid-template-columns: 60px 1fr;
    align-items: start;
    gap: 8px;
    padding: 0.5rem;
    text-align: left;
    min-height: 50px;
  }

  .session-header {
    font-weight: bold;
    color: #495057;
    padding-top: 6px;
    font-size: 0.85rem;
  }

  .schedule-content {
    text-align: left;
    padding: 6px 8px;
    border-radius: 4px;
    min-height: 35px;
    display: flex;
    align-items: center;
    font-size: 0.85rem;
  }

  .schedule-content:empty::after {
    content: "Không có lịch";
    color: #adb5bd;
    font-style: italic;
    font-size: 0.8rem;
  }

  .schedule-table td {
    border-bottom: 1px solid #dee2e6;
  }

  .schedule-table tr:last-child td {
    border-bottom: none;
  }

  .table-responsive {
    margin-top: 0.5rem;
  }

  .page-title {
    color: #2B579A !important;
  }

  .schedule-content {
    font-size: 1rem !important;
    padding: 6px 8px !important;
  }

  .schedule-location {
    font-size: 0.9rem !important;
    margin-top: 4px;
    padding-top: 2px;
  }

  .important-star {
    font-size: 1.2em;
    top: 2px;
    right: 2px;
  }

  .schedule-content.important {
    padding-right: 18px !important;
  }

  .session-block {
    display: block !important;
    padding: 0.5rem 0.75rem;
    text-align: left;
    min-height: auto;
  }

  .session-header {
    margin-bottom: 0.3rem;
    font-size: 0.9rem;
  }

  .schedule-content {
    display: block !important;
    min-height: 35px;
    padding: 6px 8px;
    border-radius: 4px;
    font-size: 0.9rem;
    text-align: left;
  }

  .schedule-location {
    display: block !important;
    margin-top: 6px;
    padding-top: 4px;
    font-size: 0.85rem !important;
    font-style: italic;
    color: #6c757d;
    border-top: 1px dashed #dee2e6;
    word-break: break-word;
  }

  button#prev-week-mobile,
  button#next-week-mobile {
    text-indent: -9999px !important;
    overflow: hidden !important;
    position: relative !important;
    white-space: nowrap !important;
  }

  button#prev-week-mobile::after {
    content: "Hôm trước" !important;
    text-indent: 0 !important;
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 0.9rem !important;
    color: #0d6efd !important;
  }

  button#next-week-mobile::after {
    content: "Hôm sau" !important;
    text-indent: 0 !important;
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 0.9rem !important;
    color: #0d6efd !important;
  }

  a.btn.btn-secondary[href*="login.php"],
  a.btn-secondary[href*="login.php"],
  .btn.btn-secondary.ms-2.flex-shrink-0 {
    position: fixed !important;
    top: 10px !important;
    right: 10px !important;
    width: 100px !important;
    height: 60px !important;
    z-index: 99999 !important;
    background-color: transparent !important;
    background: transparent !important;
    border: 0 !important;
    border-color: transparent !important;
    color: transparent !important;
    font-size: 0 !important;
    line-height: 0 !important;
    opacity: 0 !important;
    box-shadow: none !important;
    text-shadow: none !important;
    outline: none !important;
    text-decoration: none !important;
    pointer-events: auto !important;
    cursor: pointer !important;
  }

  a.btn.btn-secondary[href*="login.php"]:hover,
  a.btn.btn-secondary[href*="login.php"]:focus,
  a.btn.btn-secondary[href*="login.php"]:active,
  a.btn-secondary[href*="login.php"]:hover,
  a.btn-secondary[href*="login.php"]:focus,
  a.btn-secondary[href*="login.php"]:active,
  .btn.btn-secondary.ms-2.flex-shrink-0:hover,
  .btn.btn-secondary.ms-2.flex-shrink-0:focus,
  .btn.btn-secondary.ms-2.flex-shrink-0:active {
    background-color: transparent !important;
    background: transparent !important;
    border: 0 !important;
    border-color: transparent !important;
    color: transparent !important;
    opacity: 0 !important;
    box-shadow: none !important;
    outline: none !important;
    text-decoration: none !important;
  }

  .mobile-date-header {
    background: transparent !important;
    background-color: transparent !important;
    border: none !important;
    border-radius: 0 !important;
    padding: 0.5rem 0 !important;
    text-align: left !important;
    font-weight: bold;
    font-size: 1.1rem;
    color: #0067C0 !important;
    margin-bottom: 0.5rem;
    box-shadow: none !important;
  }

  .schedule-table td.leader-info {
    background-color: #0067C0 !important;
    color: white !important;
    text-align: center;
    padding: 0.5rem;
    font-size: 1rem;
    border-bottom: 2px solid #0067C0 !important;
    min-height: auto;
  }

  .schedule-table td.leader-info small {
    color: #b3d9ff !important;
  }

  button#prev-week-mobile,
  button#next-week-mobile {
    background-color: white !important;
    color: #0067C0 !important;
    border: 1px solid #0067C0 !important;
    transition: none !important;
  }

  button#prev-week-mobile:active,
  button#next-week-mobile:active {
    background-color: white !important;
    color: #0067C0 !important;
    border: 1px solid #0067C0 !important;
    box-shadow: none !important;
    outline: none !important;
    transform: none !important;
  }

  button#prev-week-mobile:focus,
  button#next-week-mobile:focus {
    background-color: white !important;
    color: #0067C0 !important;
    border: 1px solid #0067C0 !important;
    box-shadow: none !important;
    outline: none !important;
  }

  button#prev-week-mobile:hover,
  button#next-week-mobile:hover {
    background-color: white !important;
    color: #0067C0 !important;
    border: 1px solid #0067C0 !important;
  }

  button#prev-week-mobile::after,
  button#next-week-mobile::after {
    color: #0067C0 !important;
  }

  .mobile-controls {
    margin-bottom: 0.2rem !important;
    padding-bottom: 0 !important;
  }

  .mobile-controls-row-2 {
    margin-bottom: 0.1rem !important;
  }

  .mobile-date-header {
    margin-bottom: 0.1rem !important;
    padding: 0.2rem 0 !important;
  }

  .table-responsive {
    margin-top: 0 !important;
  }

  .schedule-table tr:first-child {
    margin-top: 0 !important;
  }

  .container,
  .container-fluid {
    position: relative !important;
    padding-top: 0.5rem !important;
    padding-bottom: 0.5rem !important;
  }

  .page-title {
    margin-left: 165px !important;
    margin-top: 45px !important;
    font-size: 1.2rem !important;
    text-align: left !important;
  }

  .btn-exit-admin {
    position: absolute;
    top: 15px;  /* Cách top container-fluid 15px */
    left: 15px; /* Cách left container-fluid 15px */
    z-index: 100;
    min-width: 120px;
    height: 60px;
    padding: 0 12px;
    font-size: 0.9rem;
    font-weight: 500;
    background: #f44336;
    color: #fff !important;
    border: none;
    border-radius: 5px;
    box-shadow: 0 2px 8px rgba(244,67,54,0.15);
    transition: all 0.2s ease;
    text-decoration: none !important;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
  }
}

/* --- Chỉ cho admin mobile portrait --- */
@media (orientation: portrait) and (max-width: 992px) {
  .admin-mobile-controls {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding: 0.75rem;
  }

  .admin-mobile-controls .mobile-filter-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    padding: 0;
    margin-bottom: 0.5rem;
  }

  .admin-mobile-controls .mobile-controls-row-2 {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.75rem;
    padding: 0;
    margin: 0;
  }

  .admin-mobile-controls .btn-group {
    order: 1;
  }

  .admin-mobile-controls .filter-container {
    order: 2;
    margin: 0;
    min-width: 200px;
  }

  .admin-mobile-controls #week-title-mobile {
    display: none !important;
  }
}

/* --- Ghi đè cuối cùng cho desktop (>= 993px) --- */
@media screen and (min-width: 993px) {
  .mobile-day-header {
    display: none !important;
  }

  .schedule-table tr {
    margin-bottom: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .mobile-date-header {
    display: none !important;
  }

  button#prev-week,
  button#next-week {
    text-indent: -9999px !important;
    overflow: hidden !important;
    position: relative !important;
    white-space: nowrap !important;
  }

  button#prev-week::after {
    content: "Tuần Trước" !important;
    text-indent: 0 !important;
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 1rem !important;
    color: #0d6efd !important;
  }

  button#next-week::after {
    content: "Tuần Sau" !important;
    text-indent: 0 !important;
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 1rem !important;
    color: #0d6efd !important;
  }

  button#prev-week,
  button#next-week {
    min-width: 120px !important;
    max-width: 120px !important;
    padding: 0.375rem 0.75rem !important;
    font-size: 1rem !important;
    height: auto !important;
    line-height: 1.5 !important;
    border-radius: 0.375rem !important;
    white-space: nowrap !important;
  }

  button#prev-week::after {
    font-size: 1rem !important;
    font-weight: 400 !important;
  }

  button#next-week::after {
    font-size: 1rem !important;
    font-weight: 400 !important;
  }

  .btn#prev-week,
  .btn#next-week,
  button.btn#prev-week,
  button.btn#next-week {
    width: 120px !important;
    min-width: 120px !important;
    max-width: 120px !important;
    flex: 0 0 auto !important;
  }

  button#prev-week:hover,
  button#next-week:hover,
  .btn#prev-week:hover,
  .btn#next-week:hover {
    background-color: white !important;
    color: #0d6efd !important;
    border: 1px solid #0d6efd !important;
    box-shadow: none !important;
    outline: none !important;
    text-shadow: none !important;
    cursor: pointer !important;
  }
}

/* Button "Hôm nay" desktop */
#today,
button#today {
    background-color: #0067C0 !important;
    border-color: #0067C0 !important;
}

#today:hover,
button#today:hover {
    background-color: #005099 !important;
    border-color: #005099 !important;
}

#today:focus,
#today:active,
button#today:focus,
button#today:active {
    background-color: #004080 !important;
    border-color: #004080 !important;
    box-shadow: 0 0 0 0.25rem rgba(0, 103, 192, 0.25) !important;
}

/* ============================================
   CUSTOM DROPDOWN WITH EXTERNAL SUBMENU
============================================ */

.custom-dropdown {
    position: relative;
    display: inline-block;
}

.custom-dropdown-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-width: 200px;
    padding: 8px 16px;
    background-color: #ffffff;
    border: 1px solid #ced4da;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    color: #212529;
    cursor: pointer;
    transition: all 0.2s ease;
}

.custom-dropdown-toggle:hover {
    border-color: #0d6efd;
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.1);
}

.custom-dropdown-toggle:focus {
    outline: none;
    border-color: #0d6efd;
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}

.dropdown-arrow {
    margin-left: 12px;
    transition: transform 0.2s ease;
}

.custom-dropdown.open .dropdown-arrow {
    transform: rotate(180deg);
}

/* Dropdown Menu */
.custom-dropdown-menu {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    min-width: 100%;
    width: max-content;
    max-width: 300px;
    background-color: #ffffff;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    max-height: 400px;
    overflow-y: auto;
    display: none;
}

.custom-dropdown.open .custom-dropdown-menu {
    display: block;
}

.dropdown-list {
    list-style: none;
    margin: 0;
    padding: 8px 0;
}

.dropdown-item {
    padding: 10px 16px;
    cursor: pointer;
    transition: background-color 0.15s ease;
    color: #212529;
    font-size: 14px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    white-space: nowrap;
}

.dropdown-item:hover {
    background-color: #f8f9fa;
}

.dropdown-item.active {
    background-color: #0d6efd;
    color: #ffffff;
}

/* Item có submenu */
.dropdown-item.has-submenu:hover {
    background-color: #e9ecef;
}

.submenu-arrow {
    margin-left: 8px;
    opacity: 0.6;
}

/* Submenu Wrapper - nằm ngoài dropdown menu */
.dropdown-submenu-wrapper {
    position: fixed; /* Fixed để tính toán position chính xác */
    z-index: 2000;
    pointer-events: none; /* Cho phép click xuyên qua wrapper */
}

.dropdown-submenu-wrapper.show {
    display: block !important;
    pointer-events: auto; /* Bật lại pointer events khi hiển thị */
}

/* Submenu - hiển thị BÊN NGOÀI dropdown menu */
.dropdown-submenu {
    background-color: #ffffff;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    list-style: none;
    margin: 0;
    padding: 8px 0;
    min-width: 250px;
    max-width: 350px;
    max-height: 90vh;
    overflow-y: auto;
}

.dropdown-submenu .dropdown-item {
    white-space: nowrap;
    padding: 12px 15px;
}

.dropdown-submenu .dropdown-item:hover {
    background-color: #0d6efd;
    color: #ffffff;
}

/* Scrollbar styles */
.custom-dropdown-menu::-webkit-scrollbar,
.dropdown-submenu::-webkit-scrollbar {
    width: 6px;
}

.custom-dropdown-menu::-webkit-scrollbar-track,
.dropdown-submenu::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.custom-dropdown-menu::-webkit-scrollbar-thumb,
.dropdown-submenu::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 3px;
}

.custom-dropdown-menu::-webkit-scrollbar-thumb:hover,
.dropdown-submenu::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* ============================================
   MOBILE DROPDOWN - SUBMENU SÁT BÊN PHẢI
   ============================================ */
@media (max-width: 991px) {
    /* Parent phải là relative */
    .custom-dropdown {
        max-width: none; /* Bỏ giới hạn */
        min-width: auto;
        width: auto;
        display: inline-block;
    }
    
    /* Item cha của submenu phải là relative */
    .dropdown-item.has-submenu {
      position: static !important; /* không bắt buộc relative */
    }
    
    /* Submenu wrapper - QUAN TRỌNG: parent là .has-submenu chứ không phải .custom-dropdown */
    .dropdown-submenu-wrapper {
      position: fixed !important;   /* thay vì absolute */
      left: auto !important;        /* JS sẽ đặt left */
      top: auto !important;         /* JS sẽ đặt top  */
      transform: none !important;
      margin: 0 !important;
      padding: 0 !important;
      min-width: 170px;
      max-width: 45vw;
      z-index: 2000;
      display: none;
      background: transparent;
      pointer-events: none;         /* khớp desktop */
    }
    
    .dropdown-submenu-wrapper.show {
        display: block !important;
        pointer-events: auto;
      }

    /* Submenu dropdown */
    .dropdown-submenu {
      box-shadow: 0 4px 16px rgba(0,0,0,.10);
      border-radius: 8px;
      min-width: 170px;
      max-width: 45vw;
      max-height: 70vh;
      overflow-y: auto;
      margin: 0 !important;
      background: #fff;
    }
    
    /* Overlay không dùng */
    .dropdown-overlay {
        display: none !important;
    }
    
    /* Custom dropdown menu */
    .custom-dropdown-menu {
        min-width: auto !important;
        width: max-content !important; /* Tự động theo nội dung */
        max-width: calc(100vw - 40px) !important; /* Chỉ giới hạn = màn hình - 40px margin */
        padding: 8px 0;
    }
    
    /* Toggle button */
    .custom-dropdown-toggle {
        min-width: auto; /* Bỏ min-width cố định */
        width: auto;
        max-width: none; /* Bỏ giới hạn max-width */
        padding-left: 12px;
        padding-right: 30px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* Item trong menu */
    .dropdown-item {
        white-space: nowrap; /* Không wrap text */
        padding: 10px 16px;
    }
    
    /* Item có submenu */
    .dropdown-item.has-submenu {
        padding-right: 30px; /* Chỗ cho mũi tên */
    }
}

