/* ==========================
   GLOBAL ELEMENT STYLES
   ========================== */
::placeholder {
  opacity: 1;
  color: var(--bs-gray-600) !important;
}

.label-placeholder::placeholder {
  opacity: 1;
  color: var(--bs-gray-750) !important;
}

body {
  background-image: var(--user-bg);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  transition: background-image 0.4s ease;
}

/* ==========================
   UTILITY CLASSES
   ========================== */
.pt-5px {
  padding-top: 5px !important;
}

.w-min {
  width: 1%;
  white-space: nowrap;
}

.w-50px {
  width: 50px;
}

.w-64px {
  width: 64px;
}

.w-72px {
  width: 72px;
}

.h-150px {
  height: 150px;
}

.h-600px {
  height: 600px;
}

.mh-185px {
  max-height: 185px;
}

.mh-400px {
  max-height: 400px;
}

.m-w-350px {
  min-width: 350px;
}

.cursor-pointer {
  cursor: pointer;
}

.aspect-ratio-1x1 {
  aspect-ratio: 1/1;
}

.isolate {
  isolation: isolate;
}

.z-1 {
  z-index: 1;
}

.z-5 {
  z-index: 5;
}

.bg-current-color-10 {
  background-color: color-mix(in srgb, currentColor, transparent 90%);
}

/* ==========================
   LAYOUT CONTAINERS
   ========================== */
#kt_app_root {
  overflow: auto;
}

.kt_gallery {
  width: 99%;
}

.breadcrumb-item {
  position: relative;
  color: var(--bs-gray-750);
}

/* ==========================
   COMPONENT STYLES
   ========================== */
/* Menu Icon */
.menu-icon {
  color: var(--kt-text-gray-800);
  transition: all 0.3s ease;
}

.menu-icon:hover {
  color: var(--kt-primary);
  transform: translateY(-3px);
}

.btn.menu-icon i {
  font-size: 100px;
  height: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Sidebar Search */
#sidebarSearchWrapper {
  position: relative;
}

#sidebarSearchIcon {
  position: absolute;
  top: 50%;
  left: 0.75rem;
  transform: translateY(-50%);
  pointer-events: none;
  z-index: 2;
  color: #b0b0be !important;
}

#sidebarSearch {
  background-color: transparent !important;
  padding-left: 2.5rem !important;
  height: 2.25rem !important;
  color: #b0b0be !important;
  border-color: #b0b0be !important;
}

#sidebarSearch:hover,
#sidebarSearch:focus,
#sidebarSearch:active {
  border-color: #b0b0be !important;
}

#sidebarSearchWrapper:hover #sidebarSearchIcon,
#sidebarSearchWrapper:focus-within #sidebarSearchIcon,
#sidebarSearch::placeholder,
#sidebarSearch:hover::placeholder,
#sidebarSearch:focus::placeholder {
  color: #b0b0be !important;
}

/* Background Preview */
#bg-scroll-container {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  max-width: 90vw;
  justify-content: center;
}

.bg-preview {
  width: 60px;
  height: 45px;
  background-size: cover;
  background-position: center;
  border-radius: 6px;
  opacity: 0.5;
  transition: transform 0.3s ease, opacity 0.3s ease, border 0.3s ease;
  cursor: pointer;
  flex: 0 0 auto;
}

.bg-preview.active {
  width: 100px;
  height: 70px;
  border: 2px solid var(--bs-primary);
  transform: scale(1.2);
  opacity: 1;
  z-index: 2;
}

/* Media & Video */
.camera-video {
  width: 100%;
  max-width: 640px;
  border: 2px solid #ddd;
  border-radius: 8px;
}

.lecture-video {
  width: 100%;
  height: auto;
}

/* CKEditor */
.ck-content {
  min-height: 50px;
}

/* Nav Tabs */
.nav.nav-tabs.nav-line-tabs .nav-link {
  display: block;
  padding: 0.75rem 1rem;
  border-radius: 0.5rem 0.5rem 0 0;
  margin: 0 1px;
}

.nav.nav-tabs.nav-line-tabs .nav-link.active,
.nav.nav-tabs.nav-line-tabs .nav-item.show .nav-link {
  background-color: var(--bs-secondary);
  color: var(--bs-white);
}

/* Sidebar Menu Titles */
.app-sidebar .menu .menu-item .menu-link .menu-title,
.flatpickr-day {
  color: var(--bs-gray-750);
}

/* Notification Containers */
#notif-wrapper,
#notif-container,
#notif-footer {
  background-color: var(--bs-body-bg);
}

/* ==========================
   MEDIA QUERIES
   ========================== */
@media (min-width: 992px) {
  [data-kt-app-sidebar-minimize="on"][data-kt-app-sidebar-hoverable="true"] .app-sidebar:not(:hover) #sidebarSearch {
    opacity: 0;
    transition: opacity 0.3s ease !important;
  }
}

[data-kt-app-layout="dark-sidebar"] .app-sidebar .menu .menu-item .menu-link,
[data-kt-app-layout="dark-sidebar"] .app-sidebar .menu .menu-item .menu-link .menu-title {
  color: #b0b0be;
}

.menu-item.active>.menu-link {
  background-color: #2b2b40 !important;
}

.table-bordered> :not(caption)>*>* {
  border: 1px solid var(--bs-border-color) !important;
  vertical-align: middle !important;
}



.gridjs-tbody tr:last-child {
  border-bottom: 1px solid var(--bs-border-color) !important;
}

.marker-red {
  color: red !important;
}

.marker-blue {
  color: blue !important;
}

.marker-green {
  color: green !important;
}

.marker-yellow {
  color: yellow !important;
}

.marker-purple {
  color: purple !important;
}

.marker-orange {
  color: orange !important;
}

.marker-black {
  color: black !important;
}

.marker-white {
  color: white !important;
}

.marker-gray {
  color: gray !important;
}

.marker-brown {
  color: brown !important;
}

.app-container {
  padding-left: 0 !important;
  padding-right: 0 !important;
}

.app-content {
  padding-top: 0;
  padding-bottom: 0;
}

/* ==========================
   Placeholders
   ========================== */
.placeholder-pulse {
  animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes pulse {

  /* At the start and end of the animation, the opacity is 1 */
  0%,
  100% {
    opacity: 1;
  }

  /* At the middle of the animation, the opacity is lower */
  50% {
    opacity: 0.5;
  }
}

.breadcrumb-wrapper::-webkit-scrollbar {
  height: 6px;
}

.h-btn-sm {
  height: 31px;
}

.h-btn-md {
  height: 38px;
}

.h-btn-lg {
  height: 46px;
}

.kpi-container {
  container-type: inline-size;

  .card {
    height: 100% !important;
  }
}

@container (width < 1200px) {
  .kpi-container {
    &>* {
      width: calc(100% / 2) !important;
    }
  }
}

@container (width < 562px) {
  .kpi-container {
    &>* {
      width: calc(100%) !important;
    }
  }
}

textarea.form-control,
.choices__inner,
.select2-container {
  min-width: 120px !important;
}

input.form-control {
  min-width: 60px !important;
}

input:disabled:not([type="checkbox"]),
select:disabled,
textarea:disabled,
input:read-only:not(.select2-input):not([data-choices]):not(.flatpickr-input):not([type="checkbox"]):not([type="file"]),
select:read-only:not(.select2-hidden-accessible):not([data-choices]),
textarea:read-only {
  background-color: var(--bs-gray-150) !important;
}

.choices {
  &:has(select:disabled) {
    cursor: not-allowed;
    background-color: var(--bs-gray-150) !important;

    .choices__button {
      visibility: hidden !important;
    }
  }

  &.choices--readonly {
    pointer-events: none;
    cursor: default;
    background-color: var(--bs-gray-150) !important;

    .choices__button {
      visibility: hidden !important;
    }

    .choices__input {
      display: none !important;
    }
  }
}

.gridjs-tbody {
  &:has(.gridjs-tr)>tr:not(.gridjs-tr):first-child {
    display: none;
  }
}

tr.gridjs-tr.gridjs-tr-clickable {
  td.gridjs-td * {
    cursor: pointer;
  }

  td.gridjs-td *:hover {
    color: var(--bs-primary) !important;
  }
}

.custom-file-label {
  position: absolute;
  inset: 0;
  padding: 1px 1px 1px 8.28rem;
}

.object-fit-contain {
  object-fit: contain !important;
}

.text-hover-primary,
.hover-text-primary,
.text-hover.text-primary {
  transition: color 0.2s ease;
}

.text-hover-primary:hover,
.text-hover-primary:focus,
.hover-text-primary:hover,
.hover-text-primary:focus,
.text-hover.text-primary:hover,
.text-hover.text-primary:focus {
  color: var(--bs-primary) !important;
}

.text-hover-primary:hover *,
.text-hover-primary:focus *,
.hover-text-primary:hover *,
.hover-text-primary:focus *,
.text-hover.text-primary:hover *,
.text-hover.text-primary:focus * {
  color: var(--bs-primary) !important;
}

.csv-preview-wrapper {
  overflow-x: auto;
  overflow-y: hidden;
  white-space: nowrap;
}

.csv-preview-wrapper table {
  white-space: nowrap;
}

/* Grid Action Button Styles */
.grid-action-button {
  width: 50px;
  height: 50px;

}

.grid-action-label {
  white-space: nowrap;
  font-size: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* PDF Iframe */
.pdf-iframe {
  width: 100%;
  height: 500px;
}

/* Spreadsheets & Tables Overrides - Transparent with theme colors */
.jexcel_container,
.jexcel,
.jss,
.jss_container,
.jss_content,
.jss_worksheet,
.jexcel_content {
  background-color: transparent !important;
  border-color: rgba(128, 128, 128, 0.2) !important;
}

/* Force cells to be transparent with inherited text color */
.jexcel td,
.jexcel thead td,
.jexcel tbody td,
.jss td,
.jss thead td,
.jss_worksheet td,
.jss_worksheet thead td,
.jss_worksheet tbody td {
  background-color: transparent !important;
  color: inherit !important;
  border: 1px solid rgba(128, 128, 128, 0.2) !important;
}

/* Force inputs and textareas to be transparent */
.jexcel td input,
.jexcel td textarea,
.jexcel td select,
.jss td input,
.jss td textarea,
.jss td select,
.jss_worksheet td input,
.jss_worksheet td textarea,
.jss_worksheet td select {
  background-color: transparent !important;
  color: inherit !important;
}

/* Row numbers and column headers with subtle background */
.jexcel tbody td:first-child,
.jss tbody td:first-child,
.jss_worksheet tbody td:first-child,
.jexcel thead td:first-child,
.jss thead td:first-child,
.jss_worksheet thead td:first-child {
  background-color: rgba(128, 128, 128, 0.1) !important;
  color: inherit !important;
}

.jexcel thead td,
.jss thead td,
.jss_worksheet thead td {
  background-color: rgba(128, 128, 128, 0.1) !important;
  color: inherit !important;
  font-weight: 600 !important;
}

/* Light mode specific - ensure black text on white */
[data-theme="light"] .jexcel td,
[data-theme="light"] .jexcel thead td,
[data-theme="light"] .jexcel tbody td,
[data-theme="light"] .jss td,
[data-theme="light"] .jss thead td,
[data-theme="light"] .jss_worksheet td,
[data-theme="light"] .jss_worksheet thead td,
[data-theme="light"] .jss_worksheet tbody td,
[data-theme="light"] .jexcel td input,
[data-theme="light"] .jexcel td textarea,
[data-theme="light"] .jss td input,
[data-theme="light"] .jss td textarea,
[data-theme="light"] .jss_worksheet td input,
[data-theme="light"] .jss_worksheet td textarea {
  color: #000000 !important;
}

/* Dark mode specific - ensure white text on dark */
[data-theme="dark"] .jexcel td,
[data-theme="dark"] .jexcel thead td,
[data-theme="dark"] .jexcel tbody td,
[data-theme="dark"] .jss td,
[data-theme="dark"] .jss thead td,
[data-theme="dark"] .jss_worksheet td,
[data-theme="dark"] .jss_worksheet thead td,
[data-theme="dark"] .jss_worksheet tbody td,
[data-theme="dark"] .jexcel td input,
[data-theme="dark"] .jexcel td textarea,
[data-theme="dark"] .jss td input,
[data-theme="dark"] .jss td textarea,
[data-theme="dark"] .jss_worksheet td input,
[data-theme="dark"] .jss_worksheet td textarea {
  color: #ffffff !important;
}

/* Context Menu (Essential for Add/Delete Row) */
.jcontextmenu {
  z-index: 10001 !important;
  background-color: #ffffff !important;
  color: #000000 !important;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3) !important;
  border: 1px solid #ddd !important;
  padding: 5px 0 !important;
}

.jcontextmenu>div {
  padding: 8px 20px !important;
  color: #000000 !important;
  cursor: pointer !important;
}

.jcontextmenu>div:hover {
  background-color: #f1f1f1 !important;
}

/* Dark mode context menu */
[data-theme="dark"] .jcontextmenu {
  background-color: #1e1e2d !important;
  color: #ffffff !important;
  border: 1px solid #2b2b40 !important;
}

[data-theme="dark"] .jcontextmenu>div {
  color: #ffffff !important;
}

[data-theme="dark"] .jcontextmenu>div:hover {
  background-color: #2b2b40 !important;
}

/* Ensure spreadsheet container doesn't overflow improperly */
.csv-preview-wrapper {
  overflow: visible !important;
}

/* Choices.js Dark Mode Support */
[data-theme='dark'] .choices__inner,
[data-theme='dark'] .choices__list--dropdown {
  background-color: #1b1b29 !important;
  color: #ffffff !important;
  border-color: #323248 !important;
}

[data-theme='dark'] .choices__list--dropdown .choices__item--selectable {
  color: #ffffff !important;
}

[data-theme='dark'] .choices__item--selectable.is-highlighted {
  background-color: #2b2b40 !important;
}

[data-theme='dark'] .choices__input {
  background-color: transparent !important;
  color: #ffffff !important;
}

/* ==========================
   FLOATING CHAT
   ========================== */

/* Unread badge (rendered on the navbar "Ask AI" button) */
#chat-badge {
  position: absolute;
  top: -3px;
  right: -3px;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  background: #f1416c;
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  pointer-events: none;
}

/* Drawer */
#chat-drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: 360px;
  height: 100vh;
  z-index: 1059;
  background: var(--bs-body-bg, #fff);
  border-left: 1px solid var(--bs-border-color, #e4e6ef);
  box-shadow: -4px 0 24px rgba(0,0,0,0.18);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}

#chat-drawer.chat-open {
  transform: translateX(0);
}

/* Overlay */
#chat-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1058;
  background: rgba(0,0,0,0.35);
}

#chat-overlay.chat-open {
  display: block;
}

/* Drawer header */
.chat-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: var(--bs-primary, #009ef7);
  color: #fff;
  font-weight: 600;
  font-size: 0.95rem;
  flex-shrink: 0;
}

.chat-close-btn {
  background: none;
  border: none;
  color: #fff;
  opacity: 0.8;
  cursor: pointer;
  padding: 0;
  font-size: 1.1rem;
  line-height: 1;
}

.chat-close-btn:hover { opacity: 1; }

/* Messages area */
#chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.chat-bubble {
  max-width: 80%;
  padding: 8px 12px;
  border-radius: 12px;
  font-size: 0.85rem;
  line-height: 1.45;
}

.chat-bubble-self {
  background: var(--bs-primary, #009ef7);
  color: #fff;
  border-bottom-right-radius: 3px;
}

.chat-bubble-other {
  background: var(--bs-gray-200, #f1f1f4);
  color: var(--bs-gray-800, #3f4254);
  border-bottom-left-radius: 3px;
}

.chat-bubble-name {
  font-size: 0.7rem;
  font-weight: 600;
  margin-bottom: 2px;
  opacity: 0.72;
}

.chat-bubble-time {
  font-size: 0.67rem;
  margin-top: 3px;
  opacity: 0.58;
  text-align: right;
}

/* Footer input */
.chat-drawer-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid var(--bs-border-color, #e4e6ef);
  flex-shrink: 0;
}

#chat-input {
  flex: 1;
  border: 1px solid var(--bs-border-color, #e4e6ef);
  border-radius: 20px;
  padding: 8px 14px;
  font-size: 0.85rem;
  background: var(--bs-body-bg, #fff);
  color: var(--bs-body-color, #181c32);
  outline: none;
}

#chat-input:focus {
  border-color: var(--bs-primary, #009ef7);
}

#chat-send {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: var(--bs-primary, #009ef7);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s;
  padding: 0;
}

#chat-send:hover {
  background: var(--bs-primary-active, #0095e8);
}
[data-filter-type] > button:first-of-type, #table-actions button:first-of-type {
  background-color: #2b2b40 !important;
  color: var(--kt-primary-inverse) !important;
}

span[data-facet-value] {
    color: black;
}

/* ==========================
   LOADING
   ========================== */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.6);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 99999;
    visibility: hidden;
    opacity: 0;
    transition: .2s ease;
}
.loading-overlay.active {
    visibility: visible;
    opacity: 1;
}
.loading-box {
    background: white;
    padding: 40px 60px;
    border-radius: 12px;
}
.spinner {
    width: 50px;
    height: 50px;
    border: 5px solid #eee;
    border-top: 5px solid #007bff;
    border-radius: 50%;
    margin: 0 auto 20px;
    animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }