/* Artemisa integration layer for SmartAdmin v5 assets. */
html, body { min-height: 100%; }

/* Keep the SmartAdmin header responsive when legacy page markup is present. */
.app-header > .flex-grow-1 {
  min-width: 0;
  width: auto !important;
}

.app-header .app-logo,
.app-header .collapse-icon,
.app-header .dropdown {
  flex-shrink: 0;
}

.app-header .app-search {
  min-width: 10rem;
  flex: 0 1 21.875rem;
}

.app-header .app-search .form-control { width: 100%; }
.app-header .btn-system { white-space: nowrap; }
.app-header .btn-system > span { white-space: nowrap; }

/* Legacy dashboard Flot charts rely on this height utility from SmartAdmin 1.x. */
.chart-large {
  width: 100%;
  min-height: 18rem;
}
/* SmartAdmin switches the visible logo between header and sidebar by layout. */
.app-header .app-logo,
.app-sidebar .app-logo {
  --logo-width: 15rem;
  --logo-height: auto;
  justify-content: center;
}
.app-logo .app-account-logo {
  display: block;
  width: var(--logo-width);
  min-width: 0;
  max-width: 100%;
  height: auto;
  max-height: 3rem;
  margin-inline: auto;
  object-fit: contain;
}

/* Preserve the transparent account logo and its original brand colors. */
.app-logo .app-account-logo-custom {
  filter: none;
  background-color: transparent;
}
.app-logo .app-account-logo-white { filter: none; }

#left-panel {
  --artemisa-sidebar-bg: var(--app-nav-bg, var(--primary-900, #514182));
  --artemisa-sidebar-text: rgba(255, 255, 255, .9);
  --artemisa-sidebar-muted: rgba(255, 255, 255, .72);
  --artemisa-sidebar-hover: rgba(255, 255, 255, .12);
  min-width: 0;
  color: var(--artemisa-sidebar-text);
  background: var(--artemisa-sidebar-bg);
}

html[data-bs-theme="dark"] #left-panel {
  --artemisa-sidebar-bg: var(--app-nav-background, var(--app-header-background, #272b30));
  --artemisa-sidebar-text: var(--bs-body-color, #dee2e6);
  --artemisa-sidebar-muted: var(--bs-secondary-color, #adb5bd);
  --artemisa-sidebar-hover: rgba(255, 255, 255, .08);
  border-right-color: var(--bs-border-color, #495057);
}

/* Desktop keeps the brand in the header. On mobile SmartAdmin hides it there,
   places it at the top of the off-canvas sidebar, and exposes the menu button. */
@media (min-width: 992px) {
  .app-header .app-logo {
    display: flex;
    align-items: center;
    padding: .35rem .55rem;
    border-radius: .35rem;
    background: var(--app-nav-bg, var(--primary-900, #514182));
  }
}

@media (max-width: 991.98px) {
  .app-header .app-logo { display: none; }
}

html[data-bs-theme="dark"] .app-header .app-logo {
  /* Override SmartAdmin's blue navigation gradient when dark mode is active. */
  background-image: none !important;
  background-color: var(--app-header-background, #272b30) !important;
  border-right-color: var(--bs-border-color, #495057);
}

#left-panel .login-info { padding: 1rem 1.25rem .75rem; }
#left-panel .primary-nav { min-width: 0; overflow-y: auto; }
#left-panel .primary-nav > nav { padding: 0 .75rem; }

#left-panel a,
#left-panel .login-info,
#left-panel .login-info a,
#left-panel .menu-item-parent,
#left-panel .fa,
#left-panel .fas,
#left-panel .far { color: var(--artemisa-sidebar-text); }

#left-panel .login-info a:hover { color: var(--artemisa-sidebar-text); }

#left-panel ul { list-style: none; padding-left: 0; margin-bottom: 0; }

#left-panel ul ul { padding-left: 1rem; }

#left-panel .menu-item-parent { margin-left: .35rem; }
#left-panel nav > ul > li > a,
#left-panel nav li > a { display: flex; align-items: center; gap: .35rem; min-height: 2.25rem; padding: .35rem .5rem; border-radius: .35rem; text-decoration: none; }
#left-panel nav li > ul { padding-left: .75rem; }
#left-panel nav li > ul > li > a { font-size: .875rem; }

#main.app-body { min-width: 0; }

#content.app-content { min-height: calc(100vh - var(--app-header-height, 4.5rem)); }

#ribbon .breadcrumb { background: transparent; padding: 0; }

/* Compatibility for existing Artemisa content while its pages are restyled. */
.pull-left { float: left !important; }
.pull-right { float: right !important; }
/* Preserve each element's native display (table-cell, flex, inline, etc.) when visible. */
.visible-xs, .visible-sm { display: none !important; }
.no-padding { padding: 0 !important; }
.no-margin { margin: 0 !important; }
.well { padding: 1rem; border: 1px solid var(--bs-border-color, #dee2e6); border-radius: .5rem; }
.well-light { background: var(--bs-tertiary-bg, #f8f9fa); }
.page-title { font-size: 1.5rem; margin-bottom: 1.5rem; }
.txt-color-blueDark { color: var(--bs-primary, #5b4bdb); }
.txt-color-red { color: var(--bs-danger, #dc3545); }
.col-xs-12 { flex: 0 0 auto; width: 100%; }
.col-xs-11 { flex: 0 0 auto; width: 91.666667%; }

/* Restore legacy status colors with the active Bootstrap 5 theme palette. */
.txt-color-white { color: var(--bs-white, #fff) !important; }
.txt-color-darken { color: var(--bs-dark, #212529) !important; }
.txt-color-green { color: var(--bs-success, #198754) !important; }
.txt-color-teal { color: var(--bs-teal, #20c997) !important; }
.txt-color-blue { color: var(--bs-primary, #0d6efd) !important; }
.txt-color-blueLight { color: var(--bs-info, #0dcaf0) !important; }
.txt-color-orange,
.txt-color-orangeDark,
.txt-color-warning { color: var(--bs-warning-text-emphasis, #664d03) !important; }
.txt-color-gray { color: var(--bs-secondary-color, #6c757d) !important; }
.txt-color-purple { color: var(--bs-purple, #6f42c1) !important; }
.txt-color-greenDark { color: var(--bs-success-text-emphasis, #0a3622) !important; }

.bg-color-red,
.bg-color-danger { background-color: var(--bs-danger, #dc3545) !important; }
.bg-color-green,
.bg-color-success { background-color: var(--bs-success, #198754) !important; }
.bg-color-blue,
.bg-color-blueDark,
.bg-color-primary { background-color: var(--bs-primary, #0d6efd) !important; }
.bg-color-dark-blue { background-color: var(--primary-900, var(--bs-primary, #0d6efd)) !important; }
.bg-color-teal { background-color: var(--bs-teal, #20c997) !important; }
.bg-color-orange,
.bg-color-yellow,
.bg-color-warning { background-color: var(--bs-warning, #ffc107) !important; }
.bg-color-purple { background-color: var(--bs-purple, #6f42c1) !important; }
.bg-color-greenLight { background-color: var(--bs-success-bg-subtle, #d1e7dd) !important; }
.bg-color-blueLight { background-color: var(--bs-info-bg-subtle, #cff4fc) !important; }
.bg-color-default,
.bg-color-grey,
.bg-color-gray { background-color: var(--bs-secondary-bg-subtle, #e2e3e5) !important; }
.bg-color-white { background-color: var(--bs-white, #fff) !important; }
.bg-color-black,
.bg-color-dark,
.bg-color-darken { background-color: var(--bs-dark, #212529) !important; }

/* Bootstrap 5 replaced Bootstrap 3's .label-* status pills with .badge. */
.label.label-default,
.label.label-primary,
.label.label-success,
.label.label-info,
.label.label-warning,
.label.label-danger {
  display: inline-block;
  padding: .35em .65em;
  font-size: .75em;
  font-weight: 700;
  line-height: 1;
  text-align: center;
  white-space: nowrap;
  vertical-align: baseline;
  border-radius: var(--bs-badge-border-radius, .375rem);
}
.label.label-default { color: var(--bs-white, #fff) !important; background-color: var(--bs-secondary, #6c757d) !important; }
.label.label-primary { color: var(--bs-white, #fff) !important; background-color: var(--bs-primary, #0d6efd) !important; }
.label.label-success { color: var(--bs-white, #fff) !important; background-color: var(--bs-success, #198754) !important; }
.label.label-info { color: var(--bs-dark, #212529) !important; background-color: var(--bs-info, #0dcaf0) !important; }
.label.label-warning { color: var(--bs-dark, #212529) !important; background-color: var(--bs-warning, #ffc107) !important; }
.label.label-danger { color: var(--bs-white, #fff) !important; background-color: var(--bs-danger, #dc3545) !important; }

/* Normalize the old SmartAdmin form widgets inside the new Bootstrap layout. */
.app-content .content-wrapper > .row { row-gap: .75rem; }
.jarviswidget { display: block; clear: both; margin-bottom: 1.5rem; }
.jarviswidget > header {
  min-height: 3rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .5rem;
  clear: both;
}
.jarviswidget > header .nav-tabs { float: none !important; margin: 0; }
.smart-form > footer {
  clear: both;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .5rem;
  padding: 1rem 0;
  position: static;
}
.smart-form > footer .btn { float: none !important; margin: 0; }
.smart-form fieldset { clear: both; margin-bottom: 1rem; }
.smart-form section { min-width: 0; }
.smart-form .row { row-gap: .75rem; }
.smart-form .label { display: block; margin-bottom: .35rem; }
.smart-form label.input,
.smart-form label.select,
.smart-form label.textarea { display: block; width: 100%; }
.smart-form .input-group { display: flex; align-items: stretch; width: 100%; }
.smart-form .input-group .input { flex: 1 1 auto; min-width: 0; }
.smart-form .input-group-btn { display: flex; }
.smart-form .input-group-btn .btn { height: 100%; }
.smart-form .toggle { display: block; margin: .35rem 0; }

.smart-form {
  padding: 1.25rem 1.5rem;
  background: var(--bs-body-bg, #fff);
  border: 1px solid var(--bs-border-color, #dee2e6);
  border-radius: .5rem;
  box-shadow: 0 .125rem .35rem rgba(0, 0, 0, .04);
}
.smart-form fieldset {
  padding: .25rem 0 1rem;
  border-bottom: 1px solid var(--bs-border-color, #dee2e6);
}
.smart-form fieldset:last-of-type { border-bottom: 0; padding-bottom: .25rem; }
.smart-form .label { color: var(--bs-secondary-color, #6c757d); font-weight: 600; }
.smart-form .input input,
.smart-form .input select,
.smart-form .input textarea,
.smart-form label.select > select,
.smart-form label.textarea > textarea {
  min-height: 2.35rem;
  border: 1px solid var(--bs-border-color, #ced4da);
  border-radius: .3rem;
  background: var(--bs-body-bg, #fff);
  padding: .45rem .65rem;
}
.smart-form .input textarea,
.smart-form label.textarea > textarea { min-height: 6rem; }
.smart-form .input-group .input input,
.smart-form .input-group .input select { border-top-left-radius: 0; border-bottom-left-radius: 0; }
.smart-form .input-group-btn .btn { min-width: 2.5rem; }

@media (min-width: 768px) {
  .visible-sm { display: block !important; }
}

@media (max-width: 767.98px) {
  .hidden-xs { display: none !important; }
  .visible-xs { display: block !important; }
}

@media (min-width: 768px) and (max-width: 991.98px) {
  .hidden-sm { display: none !important; }
}

@media (min-width: 992px) {
  .visible-sm { display: none !important; }
}

@media (max-width: 991.98px) {
  #left-panel { transform: translateX(-100%); transition: transform .2s ease; }
  .app-mobile-menu-open #left-panel { transform: translateX(0); }
}

/* Preserve the demo navigation palette instead of fixing legacy white links. */
html:not([data-bs-theme="dark"]):not(.set-nav-dark) #left-panel {
  --artemisa-sidebar-text: var(--app-nav-link-color);
  --artemisa-sidebar-muted: var(--app-nav-link-color);
  --artemisa-sidebar-hover: var(--app-nav-item-hover-bg, transparent);
  background: var(--app-nav-background, var(--bs-body-bg));
}
html.set-nav-dark:not([data-bs-theme="dark"]) #left-panel {
  background-image: linear-gradient(270deg, rgba(var(--bs-info-rgb), .18), transparent);
  background-color: var(--app-nav-bg);
}
@media (min-width: 992px) {
  .set-nav-minified:not(.set-nav-collapsed) #left-panel:not(:hover) .login-info {
    display: none;
  }
}

/* Sidebar logo visibility remains controlled by SmartAdmin's layout rules. */
#left-panel.app-sidebar .app-logo {
  width: 100%;
  box-sizing: border-box;
  justify-content: center;
  align-items: center;
  min-height: var(--app-header-height);
  padding: .35rem .55rem;
  flex-shrink: 0;
}
/* Legacy menu labels and Font Awesome icons follow their link state. */
#left-panel nav li > a {
  color: var(--app-nav-link-color, var(--artemisa-sidebar-text));
}
#left-panel nav li > a:hover {
  color: var(--app-nav-link-hover-color, var(--artemisa-sidebar-text));
  background: var(--app-nav-item-hover-bg, var(--artemisa-sidebar-hover));
}
/* Parent items stay expanded to reveal the current route; only the selected
   leaf gets the active background, matching SmartAdmin's navigation rules. */
#left-panel nav li.active:not(.open):not(.has-ul) > a {
  color: var(--app-nav-link-active-color, var(--artemisa-sidebar-text));
  background: var(--app-nav-item-active-bg, var(--artemisa-sidebar-hover));
}
#left-panel nav li > a .menu-item-parent,
#left-panel nav li > a .fa,
#left-panel nav li > a .fas,
#left-panel nav li > a .far { color: inherit; }

/* The original dark navigation sets link colors directly, not through the
   light/high-contrast root tokens. Preserve those colors for legacy links. */
html.set-nav-dark:not([data-bs-theme="dark"]) #left-panel nav li:not(.active) > a {
  color: rgba(255, 255, 255, .6);
}
html.set-nav-dark:not([data-bs-theme="dark"]) #left-panel nav li:not(.active) > a:hover {
  color: rgba(255, 255, 255, .9);
}
/* High-contrast mode sets the generic link token to black. Keep an active
   expandable parent at the same muted color as the other dark-nav headings. */
html.set-nav-dark:not([data-bs-theme="dark"]) #left-panel nav li.active.has-ul > a {
  color: rgba(255, 255, 255, .6);
}
