/* Subtle glassmorphism overlays to modernize UI without breaking layout */

/* Smooth transitions for common surfaces */
body, .navbar, .card, .dropdown-menu, .modal-content {
  transition: background-color 180ms ease, color 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

/* Cards */
.card {
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid rgba(0, 0, 0, 0.06);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.08);
}

/* Dropdown & Modal surfaces */
.dropdown-menu,
.modal-content {
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid rgba(0, 0, 0, 0.06);
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.12);
}

/* Add blur where supported */
@supports (backdrop-filter: blur(6px)) or (-webkit-backdrop-filter: blur(6px)) {
  .card,
  .dropdown-menu,
  .modal-content {
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
  }
}

/* Dark mode tuning via html[data-mode] from theme-bridge */
[data-mode="dark"] .card {
  background: rgba(19, 22, 30, 0.64);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.35);
}

[data-mode="dark"] .dropdown-menu,
[data-mode="dark"] .modal-content {
  background: rgba(17, 20, 28, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.10);
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.45);
}

/* Login specific glass card at alpha 0.5 */
.card.glass-50 {
  background: rgba(255, 255, 255, 0.5) !important;
  border: 1px solid rgba(0, 0, 0, 0.06);
}

[data-mode="dark"] .card.glass-50 {
  background: rgba(16, 18, 24, 0.5) !important;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

/* Constrain login card width for a narrower look while staying responsive */
.login-card {
  max-width: 720px;
  margin-left: auto;
  margin-right: auto;
}

/* Login input icon backgrounds */
.login-card .input-group-prepend .input-group-text {
  background: rgba(255, 255, 255, 0.6);
  border-color: rgba(0,0,0,0.06);
  transition: background-color .2s ease, border-color .2s ease, box-shadow .2s ease;
}

[data-mode="dark"] .login-card .input-group-prepend .input-group-text {
  background: rgba(16, 18, 24, 0.55);
  border-color: rgba(255,255,255,0.20);
  color: #ffffff !important;
  box-shadow: 0 4px 14px rgba(0,0,0,0.25);
}

@supports (backdrop-filter: blur(6px)) or (-webkit-backdrop-filter: blur(6px)) {
  [data-mode="dark"] .login-card .input-group-prepend .input-group-text {
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
  }
}

/* Force feather svg to white outlines in dark mode */
[data-mode="dark"] .login-card .input-group-prepend .input-group-text svg {
  color: #ffffff !important;
  stroke: #ffffff !important;
}

/* Section that fits exactly between fixed header and footer */
.between-header-footer {
  /* Occupy the viewport minus fixed chrome and center content */
  min-height: calc(100vh - var(--header-h, 64px) - var(--footer-h, 64px));
  margin-top: var(--header-h, 64px);
  margin-bottom: var(--footer-h, 64px);
  display: flex;
  align-items: center;
}

/* Compact quick-link cards on dashboard */
.quicklink-card .card-body {
  padding: 0.75rem 0.75rem;
}

.quicklink-card .mb-3 { /* tighten icon spacing */
  margin-bottom: 0.5rem !important;
}

.quicklink-card .icon.icon-shape {
  width: 2.25rem;
  height: 2.25rem;
}

.quicklink-card .icon.icon-shape i,
.quicklink-card .icon.icon-shape svg {
  font-size: 1rem;
  width: 1rem;
  height: 1rem;
}

.quicklink-card h5 {
  font-size: 0.95rem;
  line-height: 1.2;
  margin-bottom: 0.25rem;
}

/* ----------------------------------------------
   Main menu frame card with animated neon border
   ---------------------------------------------- */
.menu-frame {
  position: relative;
  overflow: hidden;
  border-radius: .75rem;
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid rgba(0,0,0,0.06);
  box-shadow: 0 10px 30px rgba(0,0,0,0.08);
}
@supports (backdrop-filter: blur(6px)) or (-webkit-backdrop-filter: blur(6px)) {
  .menu-frame { backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
}

[data-mode="dark"] .menu-frame {
  background: rgba(16, 18, 24, 0.55);
  border: 1px solid rgba(255,255,255,0.08);
  box-shadow: 0 14px 36px rgba(0,0,0,0.36);
}

/* Animated gradient border using a masking trick */
.menu-frame::before {
  content: "";
  position: absolute;
  inset: 0;
  padding: 2px; /* border thickness */
  border-radius: inherit;
  background: linear-gradient(90deg, #7a5af8, #3bb2ff, #7a5af8);
  background-size: 200% 100%;
  animation: menuBorderFlow 6s linear infinite;
  mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}

@keyframes menuBorderFlow {
  0% { background-position: 0% 0%; }
  100% { background-position: 200% 0%; }
}

@media (prefers-reduced-motion: reduce) {
  .menu-frame::before { animation: none; }
}

/* Make quick links friendlier on very small screens */
@media (max-width: 575.98px) {
  .quicklink-card .card-body { padding: 1rem; }
  .quicklink-card .icon.icon-shape { width: 2.5rem; height: 2.5rem; }
  .quicklink-card .icon.icon-shape i,
  .quicklink-card .icon.icon-shape svg { width: 1.1rem; height: 1.1rem; font-size: 1.1rem; }
  .quicklink-card h5 { font-size: 1.05rem; }
}

/* Animated gradient navbar (light theme only) */
@keyframes navbarGradient {
  0% { background-position: 0% 0%; }
  50% { background-position: 100% 0%; }
  100% { background-position: 0% 0%; }
}

[data-mode="light"] .navbar.navbar-light.bg-white {
  background: linear-gradient(90deg,
              rgba(255,255,255,0.98),
              rgba(227, 244, 255, 0.98),
              rgba(255,255,255,0.98)) !important;
  background-size: 300% 100% !important;
  animation: navbarGradient 14s ease-in-out infinite;
  border-bottom: 1px solid rgba(0,0,0,0.06);
}

@media (prefers-reduced-motion: reduce) {
  [data-mode="light"] .navbar.navbar-light.bg-white { animation: none; }
}

/* Dark mode animated gradients for navbar and footer to match */
[data-mode="dark"] .navbar.navbar-dark.bg-dark {
  background: linear-gradient(90deg,
              rgba(9,12,18,0.96),
              rgba(16,22,34,0.96),
              rgba(9,12,18,0.96)) !important;
  background-size: 300% 100% !important;
  animation: navbarGradient 20s ease-in-out infinite;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

[data-mode="dark"] #footer-main {
  background: linear-gradient(90deg,
              rgba(9,12,18,0.96),
              rgba(16,22,34,0.96),
              rgba(9,12,18,0.96)) !important;
  background-size: 300% 100% !important;
  animation: navbarGradient 20s ease-in-out infinite;
  border-top: 1px solid rgba(255,255,255,0.08);
}

@media (prefers-reduced-motion: reduce) {
  [data-mode="dark"] .navbar.navbar-dark.bg-dark,
  [data-mode="dark"] #footer-main { animation: none; }
}

/* Theme toggle as a purple nav link pill */
.navbar .nav-link.theme-toggle-link {
  background-image: linear-gradient(135deg, #7a5af8 0%, #9c5cff 100%);
  color: #fff !important;
  border-radius: 999px;
  box-shadow: 0 6px 18px rgba(122, 90, 248, 0.35);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: .5rem 1rem !important; /* match nav-link vertical rhythm */
  line-height: 1.2;
}
.navbar .nav-link.theme-toggle-link i { color: #fff !important; }
.navbar .nav-link.theme-toggle-link:hover { filter: brightness(1.05); box-shadow: 0 8px 22px rgba(122, 90, 248, 0.45); }
.navbar .nav-link.theme-toggle-link:active { transform: translateY(1px); }

/* Navbar links — slightly more engaging */
.navbar .nav-link {
  position: relative;
  border-radius: .375rem;
  transition: background-color .2s ease, color .2s ease;
}
.navbar .nav-link:hover {
  background-color: rgba(10, 120, 255, 0.08);
}
[data-mode="dark"] .navbar .nav-link:hover {
  background-color: rgba(255, 255, 255, 0.08);
}

/* Footer animated gradient (same as navbar, light mode) */
[data-mode="light"] #footer-main {
  background: linear-gradient(90deg,
              rgba(255,255,255,0.98),
              rgba(227, 244, 255, 0.98),
              rgba(255,255,255,0.98)) !important;
  background-size: 300% 100% !important;
  animation: navbarGradient 14s ease-in-out infinite;
  border-top: 1px solid rgba(0,0,0,0.06);
}

@media (prefers-reduced-motion: reduce) {
  [data-mode="light"] #footer-main { animation: none; }
}


/* Keep white navbar crisp in light mode; soften only when dark */
[data-mode="dark"] .navbar.navbar-dark {
  background: rgba(16, 18, 24, 0.76) !important;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
}

/* Buttons — ensure outline variants are readable on dark */
[data-mode="dark"] .btn-outline-secondary {
  color: #e2e6ea !important;
  border-color: rgba(226, 230, 234, 0.45) !important;
}

[data-mode="dark"] .btn-outline-secondary:hover {
  background: rgba(255, 255, 255, 0.08) !important;
  border-color: rgba(226, 230, 234, 0.65) !important;
}

/* Avoid overly transparent table backgrounds for readability */
.table { background-color: transparent; }
[data-mode="dark"] .table-hover tbody tr:hover {
  background-color: rgba(255, 255, 255, 0.06);
}

/* ----------------------------------------------
   Compact App Grid (replaces bulky cards)
   ---------------------------------------------- */
.app-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: .75rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.app-tile {
  position: relative;
  display: grid;
  grid-template-rows: auto auto;
  justify-items: center;
  align-content: center;
  padding: .75rem .5rem;
  border-radius: .5rem;
  background: rgba(255,255,255,.45);
  border: 1px solid rgba(0,0,0,.06);
  text-align: center;
  text-decoration: none;
  color: inherit;
  transition: transform .15s ease, box-shadow .15s ease, background-color .15s ease;
}
[data-mode="dark"] .app-tile {
  background: rgba(16,18,24,.45);
  border: 1px solid rgba(255,255,255,.08);
}
.app-tile:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(0,0,0,.12); }
.app-tile:focus { outline: 2px solid rgba(122,90,248,.6); outline-offset: 2px; }

.app-icon {
  display: inline-flex; align-items:center; justify-content:center;
  width: 2.5rem; height: 2.5rem; border-radius: .5rem; color:#fff;
  box-shadow: 0 6px 16px rgba(0,0,0,.12);
}
.app-label { margin-top: .5rem; font-size: .95rem; line-height: 1.2; }

.pin-btn {
  position: absolute; top: .35rem; right: .35rem; width: 1.35rem; height: 1.35rem;
  border: 0; border-radius: 999px; background: radial-gradient(ellipse at 30% 30%, #ffd166, #ff9e00);
  cursor: pointer; opacity: .0; transition: opacity .15s ease, transform .15s ease;
  display:flex; align-items:center; justify-content:center;
  box-shadow: 0 2px 8px rgba(255,158,0,.35);
}
.pin-btn i { color: #fff; font-size: .65rem; }
.app-tile:hover .pin-btn, .app-tile.pinned .pin-btn { opacity: .9; }
.app-tile.pinned { outline: 2px solid rgba(122,90,248,.6); outline-offset: 2px; }

@media (max-width: 575.98px) {
  .app-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .app-icon { width: 2.25rem; height: 2.25rem; }
  .app-label { font-size: 1.02rem; }
}

/* Compact list-style menu */
.section-title {
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: rgba(0,0,0,.72);
  margin: .75rem 0 .5rem 0;
}
[data-mode="dark"] .section-title { color: rgba(255,255,255,.75); }
.section-title::after {
  content: "";
  display: block;
  height: 2px;
  width: 64px;
  margin: .35rem auto 0 auto;
  background: linear-gradient(90deg, #7a5af8, #3bb2ff);
  border-radius: 2px;
}

.menu-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: .5rem;
  padding: 0;
  margin: 0 0 1rem 0;
  list-style: none;
}
.menu-link {
  display: flex;
  align-items: center;
  min-height: 48px;
  padding: .5rem .75rem;
  border-radius: .5rem;
  background: rgba(255,255,255,.45);
  border: 1px solid rgba(0,0,0,.06);
  color: inherit;
  text-decoration: none;
  transition: transform .15s ease, box-shadow .15s ease, background-color .15s ease;
}
[data-mode="dark"] .menu-link { background: rgba(16,18,24,.45); border: 1px solid rgba(255,255,255,.08); }
.menu-link:hover { transform: translateY(-1px); box-shadow: 0 8px 18px rgba(0,0,0,.10); }
.menu-icon { width: 2.5rem; height: 2.5rem; border-radius: .4rem; color: #fff; display:inline-flex; align-items:center; justify-content:center; box-shadow: 0 6px 16px rgba(0,0,0,.14); }
.menu-text { margin-left: .6rem; font-size: .95rem; line-height: 1.2; }

/* ----------------------------------------------
   Menu carousel slide layout
   ---------------------------------------------- */
.menu-carousel .carousel-item { padding: .25rem 0; }
.menu-carousel .card-body {
  /* Maintain a consistent tall frame regardless of slide content */
  min-height: max(560px, calc(80vh - var(--header-h, 64px) - var(--footer-h, 64px)));
  position: relative;              /* anchor indicators */
  padding-bottom: 6.5rem;          /* reserve extra space for indicators */
  display: flex;                   /* vertically center #menuCarousel */
  align-items: center;
  justify-content: center;
}
.menu-carousel #menuCarousel {
  width: 100%;
  max-width: 80%;  /* occupy at most 80% of available width */
  margin-left: auto;
  margin-right: auto;
  padding-left: 3.75rem;   /* leave room for controls */
  padding-right: 3.75rem;  /* leave room for controls */
}

/* Keep stacked list from touching indicators */
.menu-carousel .menu-list.menu-stack { margin-bottom: 2.5rem; }
.menu-carousel .carousel-indicators {
  position: absolute;
  left: 0; right: 0;
  margin: 0;                       /* prevent default offset */
  justify-content: center;
  z-index: 2;
}

/* Tabbed header style for menu (alternative to carousel) */
.menu-tabs .nav-link {
  margin: 0 .25rem;
  border-radius: 999px;
  background: rgba(255,255,255,.08);
  color: inherit;
  padding: .4rem .9rem;
  transition: background-color .2s ease, box-shadow .2s ease;
}
[data-mode="dark"] .menu-tabs .nav-link { background: rgba(255,255,255,.06); }
.menu-tabs .nav-link:hover { background: rgba(122,90,248,.12); }
.menu-tabs .nav-link.active {
  color: #fff !important;
  background-image: linear-gradient(135deg, #7a5af8 0%, #3bb2ff 100%);
  box-shadow: 0 6px 18px rgba(122, 90, 248, 0.35);
}
.menu-slide .slide-hero {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  min-height: 220px;
}
.menu-slide .slide-title {
  font-size: 1.25rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-top: .5rem;
}
.menu-slide .slide-icon {
  width: 80px; height: 80px; border-radius: 1rem; color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  box-shadow: 0 12px 28px rgba(0,0,0,.18);
  animation: floatY 3.5s ease-in-out infinite;
}
/* Ensure the FA glyph fills the badge comfortably */
.menu-slide .slide-icon i,
.menu-slide .slide-icon .svg-inline--fa {
  font-size: 2.25rem; /* ~36px fits well in 80px badge */
  line-height: 1;
}
@media (min-width: 992px) {
  .menu-slide .slide-icon { width: 88px; height: 88px; }
  .menu-slide .slide-icon i,
  .menu-slide .slide-icon .svg-inline--fa { font-size: 2.5rem; }
}
@keyframes floatY {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

/* In tabbed layout, arrange rows responsively rather than strictly stacked */
.menu-list.menu-stack {
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

/* Carousel controls subtle neon look */
.menu-carousel .carousel-control-prev, .menu-carousel .carousel-control-next {
  position: absolute;
  width: 3.25rem;
  height: 3.25rem;
  top: 50%;
  bottom: auto;
  transform: translateY(-70%);
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 50%;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  box-shadow: 0 8px 22px rgba(0,0,0,0.25);
}
.menu-carousel .carousel-control-prev { left: 0; }
.menu-carousel .carousel-control-next { right: 0; }
.menu-carousel .carousel-control-prev:hover,
.menu-carousel .carousel-control-next:hover {
  background: rgba(122,90,248,0.18);
  border-color: rgba(122,90,248,0.45);
}
.menu-carousel .carousel-control-prev-icon, .menu-carousel .carousel-control-next-icon {
  filter: drop-shadow(0 2px 6px rgba(0,0,0,.25));
}

/* On smaller screens keep controls inside with small gutters */
@media (max-width: 991.98px) {
  .menu-carousel #menuCarousel { padding-left: 3rem; padding-right: 3rem; }
  .menu-carousel .carousel-control-prev { left: 0; }
  .menu-carousel .carousel-control-next { right: 0; }
}

/* ----------------------------------------------
   Tool Manager darker glass frame for better form readability
   ---------------------------------------------- */
.tool-manager-frame {
  position: relative;
  border-radius: .75rem;
  background: rgba(255, 255, 255, 0.70);
  border: 1px solid rgba(0,0,0,0.08);
  box-shadow: 0 10px 30px rgba(0,0,0,0.10);
  margin: 1rem;
  overflow: hidden;
}

@supports (backdrop-filter: blur(0)) or (-webkit-backdrop-filter: blur(0)) {
  .tool-manager-frame {
    backdrop-filter: saturate(140%) blur(10px);
    -webkit-backdrop-filter: saturate(140%) blur(10px);
  }
}

[data-mode="dark"] .tool-manager-frame {
  background: rgba(16, 18, 24, 0.70);
  border: 1px solid rgba(255,255,255,0.10);
  box-shadow: 0 14px 36px rgba(0,0,0,0.40);
}

/* Animated gradient border using a masking trick (same as menu-frame) */
.tool-manager-frame::before {
  content: "";
  position: absolute;
  inset: 0;
  padding: 2px; /* border thickness */
  border-radius: inherit;
  background: linear-gradient(90deg, #7a5af8, #3bb2ff, #7a5af8);
  background-size: 200% 100%;
  animation: menuBorderFlow 6s linear infinite;
  mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
  .tool-manager-frame::before { animation: none; }
}

/* Responsive adjustments for small screens */
@media (max-width: 575.98px) {
  .tool-manager-frame {
    margin: .5rem;
  }
  .tool-manager-frame .container-fluid {
    padding-left: 1rem !important;
    padding-right: 1rem !important;
  }
}

/* ----------------------------------------------
   Select2 Glassmorphism Dropdown Styling
   ---------------------------------------------- */
.select2-dropdown {
  background: rgba(255, 255, 255, 0.90) !important;
  border: 1px solid rgba(0,0,0,0.08) !important;
  box-shadow: 0 10px 30px rgba(0,0,0,0.10) !important;
  border-radius: .5rem;
}

@supports (backdrop-filter: blur(0)) or (-webkit-backdrop-filter: blur(0)) {
  .select2-dropdown {
    backdrop-filter: saturate(140%) blur(10px);
    -webkit-backdrop-filter: saturate(140%) blur(10px);
  }
}

[data-mode="dark"] .select2-dropdown {
  background: rgba(16, 18, 24, 0.92) !important;
  border: 1px solid rgba(255,255,255,0.10) !important;
  box-shadow: 0 14px 36px rgba(0,0,0,0.40) !important;
}

/* Reduce blur on small screens for performance */
@media (max-width: 575.98px) {
  .select2-dropdown {
    backdrop-filter: saturate(120%) blur(6px);
    -webkit-backdrop-filter: saturate(120%) blur(6px);
  }
}

/* Select2 option hover state with explicit text color */
.select2-results__option--highlighted {
  background: rgba(122, 90, 248, 0.15) !important;
  color: #111 !important;
}

[data-mode="dark"] .select2-results__option--highlighted {
  background: rgba(122, 90, 248, 0.25) !important;
  color: #fff !important;
}

/* Select2 option selected state */
.select2-results__option[aria-selected="true"] {
  background: rgba(122, 90, 248, 0.20) !important;
  color: #111 !important;
}

[data-mode="dark"] .select2-results__option[aria-selected="true"] {
  background: rgba(122, 90, 248, 0.32) !important;
  color: #fff !important;
}

/* Select2 search field (if present) */
.select2-search--dropdown .select2-search__field {
  background: rgba(255, 255, 255, 0.50) !important;
  border-color: rgba(0,0,0,0.10) !important;
}

.select2-search--dropdown .select2-search__field::placeholder {
  color: rgba(0,0,0,0.6);
}

[data-mode="dark"] .select2-search--dropdown .select2-search__field {
  background: rgba(16, 18, 24, 0.50) !important;
  border-color: rgba(255,255,255,0.15) !important;
  color: #fff !important;
}

[data-mode="dark"] .select2-search--dropdown .select2-search__field::placeholder {
  color: rgba(255,255,255,0.7);
}
