/* Shared UI consistency layer (fonts, links, footers, buttons).
   Keep selectors low-specificity to avoid breaking page-specific designs. */

:root {
  --ui-font-sans: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  --ui-brand-1: #b2cd16;
  --ui-brand-2: #9ef755;
  --ui-muted: #a0aec0;
  --ui-divider: #e2e8f0;
  --ui-shadow-brand: 0 10px 25px rgba(178, 205, 22, 0.3);
  --navbar-height: 90px;
}

html,
body {
  font-family: var(--ui-font-sans);
  background-color: #ffffff !important;
  background: #ffffff !important;
  height: 100%;
  overflow: hidden;
}

body {
  overflow-x: hidden;
}

/* Scroll lives in main so the bar starts directly under the fixed navbar */
main,
main.content {
  position: fixed;
  top: var(--navbar-height);
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  margin-top: 0 !important;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-gutter: stable;
  box-sizing: border-box;
  min-height: 0 !important;
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 #f1f5f9;
}

main::-webkit-scrollbar,
main.content::-webkit-scrollbar {
  width: 12px;
}

main::-webkit-scrollbar-track,
main.content::-webkit-scrollbar-track {
  background: #f1f5f9;
}

main::-webkit-scrollbar-thumb,
main.content::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 6px;
  border: 2px solid #f1f5f9;
}

main::-webkit-scrollbar-thumb:hover,
main.content::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* Mobile navbar: logo left, menu button right */
@media (max-width: 992px) {
  :where(nav.navbar, header.navbar) {
    justify-content: flex-start;
    gap: 12px;
  }

  :where(nav.navbar, header.navbar) :where(.navbar-logo, .logo) {
    order: 1;
    margin-left: 0 !important;
    margin-right: 0 !important;
  }

  :where(nav.navbar, header.navbar) .mobile-menu-btn {
    order: 2;
    margin-left: auto !important;
    margin-right: 0 !important;
  }
}

/* Horizontal scroll areas should expose the start column */
:where(.table-scroll-x) {
  direction: ltr;
  scroll-padding-inline-start: 0;
}

main,
main.content {
  background-color: #ffffff;
}

.login-logo,
.auth-logo {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 12px;
}

.login-logo img,
.auth-logo img {
  display: block;
  max-width: min(280px, 100%);
  width: auto;
  height: auto;
  max-height: 110px;
  object-fit: contain;
}

/* Keep top navigation bars white across all roles/layouts */
nav.navbar,
header.navbar,
.navbar {
  background-color: #ffffff !important;
  background: #ffffff !important;
}

/* Brand logo — visible on desktop and mobile across all layouts */
:where(nav.navbar, header.navbar) :where(.navbar-logo, .logo) {
  display: flex !important;
  align-items: center;
  flex-shrink: 0;
  min-width: 0;
}

:where(nav.navbar, header.navbar) :where(.navbar-logo a, .logo a) {
  display: inline-flex;
  align-items: center;
  line-height: 0;
}

:where(nav.navbar, header.navbar) :where(.navbar-logo img, .logo img) {
  display: block;
  height: 80px;
  width: auto;
  max-width: min(220px, 42vw);
  object-fit: contain;
}

@media (max-width: 992px) {
  :where(nav.navbar, header.navbar) :where(.navbar-logo img, .logo img) {
    height: 44px;
    max-width: min(160px, 48vw);
  }
}

nav.menu a,
.menu .nav-link,
.nav-item.dropdown > a {
  background-color: transparent;
}

.dropdown-menu.notifications-dropdown,
.dropdown-menu.notifications-dropdown .dropdown-header {
  background-color: #ffffff;
}

/* Hide browser-native password reveal (Edge/IE) when custom eye toggles are used */
.input-wrapper input[type="password"]::-ms-reveal,
.input-wrapper input[type="password"]::-ms-clear,
.password-toggle input[type="password"]::-ms-reveal,
.password-toggle input[type="password"]::-ms-clear,
.has-toggle input[type="password"]::-ms-reveal,
.has-toggle input[type="password"]::-ms-clear {
  display: none;
}

/* Mobile responsiveness helpers (dashboards, cards, headings)
   Uses common container/card classnames already in views. */
@media (max-width: 768px) {
  /* Global mobile typography (content only) */
  main :where(h1) { font-size: 26px !important; }
  main :where(h2) { font-size: 20px !important; }
  main :where(h3) { font-size: 16px !important; }
  main :where(p, li, td, th, label, input, select, button, a) { font-size: 14px; }

  /* Tables: horizontal scroll on mobile (all sides/pages) */
  main :where(table) {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-collapse: collapse;
  }

  /* Buttons: shrink on mobile so they fit */
  main :where(button, input[type="submit"], input[type="button"], .btn, a.btn) {
    font-size: 14px !important;
    padding: 8px 12px !important;
    border-radius: 10px !important;
    line-height: 1.15 !important;
  }
  /* Big "Add" links/buttons in admin pages */
  main :where(.add-employee-button) {
    font-size: 14px !important;
    padding: 8px 12px !important;
    float: none !important;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    margin: 10px 0 0 0 !important;
  }
  /* Search/filter rows: allow wrapping instead of overflow */
  main :where(.search-row, .filter-export-container, .filter-export-container form) {
    flex-wrap: wrap !important;
  }
  main :where(.search-row input, .filter-export-container input) {
    width: 100% !important;
    max-width: 100% !important;
  }
  main :where(.search-row button, .search-row a) {
    flex: 1 1 auto !important;
    justify-content: center;
    text-align: center;
  }
  main :where(table) :where(th, td) {
    white-space: nowrap;
  }
  /* Make sure inner table doesn't squish columns too much */
  main :where(table) {
    min-width: 100%;
  }

  /* If a table is wrapped in an explicit scroll container, force overflow */
  main :where(.table-scroll-x) {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
    min-width: 0 !important;
    /* Let horizontal scroll reach the last column (avoid pan-x fighting touch on iOS) */
    touch-action: auto;
    overscroll-behavior-x: contain;
  }
  main :where(.table-scroll-x > table) {
    display: table !important;
    width: max-content !important;
    min-width: 720px !important;
    border-collapse: separate;
    overflow: visible !important;
    overflow-x: visible !important;
  }

  :where(.dashboard-container, .manager-container, .admin-container) {
    padding-left: 12px !important;
    padding-right: 12px !important;
    border-radius: 16px !important;
  }

  :where(.dashboard-container, .manager-container, .admin-container) h1 {
    font-size: 26px !important;
    margin-bottom: 16px !important;
    padding-left: 10px !important;
  }

  :where(.dashboard-container, .manager-container, .admin-container) h2 {
    font-size: 20px !important;
  }

  :where(.dashboard-container, .manager-container, .admin-container) h3 {
    font-size: 16px !important;
  }

  /* Summary cards ("Pending", "Approved", etc.) */
  :where(.dashboard-container, .manager-container, .admin-container) .cards {
    flex-wrap: wrap !important;
    overflow-x: visible !important;
    gap: 12px !important;
  }

  :where(.dashboard-container, .manager-container, .admin-container) .cards .card {
    width: auto !important;
    max-width: none !important;
    min-width: 0 !important;
    flex: 1 1 calc(50% - 12px) !important;
    height: auto !important;
    min-height: 84px !important;
    padding: 10px 10px !important;
  }

  :where(.dashboard-container, .manager-container, .admin-container) .card-title {
    font-size: 0.95rem !important;
    margin: 2px 0 6px 0 !important;
  }

  :where(.dashboard-container, .manager-container, .admin-container) .card-value {
    font-size: 1.35rem !important;
  }

  /* Request pages: make wide tables usable on mobile */
  :where(.leave-container, .page-container) {
    padding: 16px 12px !important;
    margin: 12px auto !important;
  }
  :where(.leave-title) { font-size: 26px !important; margin-bottom: 14px !important; }
  :where(.leave-header-flex) { flex-wrap: wrap !important; gap: 10px !important; }
  :where(.leave-table) { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  :where(.leave-table th, .leave-table td) { padding: 10px 12px !important; white-space: nowrap; }
}

@media (max-width: 420px) {
  :where(.dashboard-container, .manager-container, .admin-container) .cards .card {
    flex-basis: 100% !important;
  }
}

/* Hide browser-native password reveal when a custom toggle is present (Edge/IE) */
.input-wrapper input[type="password"]::-ms-reveal,
.input-wrapper input[type="password"]::-ms-clear,
.password-toggle input[type="password"]::-ms-reveal,
.password-toggle input[type="password"]::-ms-clear {
  display: none;
}

/* Consistent auth form headings */
.auth-title {
  text-align: center;
  margin: 0 0 18px;
  font-size: 24px;
  font-weight: 700;
  color: #2d3748;
  letter-spacing: -0.2px;
}

/* Footer / "All rights reserved" */
.branding {
  text-align: center;
  margin-top: 18px;
  font-size: 12px;
  color: var(--ui-muted);
}

/* Subtle divider used above footer link blocks */
.links,
.extra-links {
  border-top: 1px solid var(--ui-divider);
}

/* Consistent underline-on-hover for “text under buttons” links */
.links a,
.extra-links a {
  color: var(--ui-brand-1);
  font-weight: 600;
  text-decoration: none;
  position: relative;
  transition: color 0.3s ease;
}

.links a::after,
.extra-links a::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -2px;
  height: 2px;
  width: 0;
  background: var(--ui-brand-1);
  transition: width 0.3s ease;
}

.links a:hover::after,
.extra-links a:hover::after {
  width: 100%;
}

.links a:hover,
.extra-links a:hover {
  color: var(--ui-brand-2);
}

/* Button consistency without overriding Bootstrap coloring */
:where(button, input[type="submit"], input[type="button"], .btn, .btn-login) {
  font-family: inherit;
  border-radius: 10px;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

:where(button, input[type="submit"], input[type="button"]):hover {
  transform: translateY(-1px);
}

/* Gradient hover “polish” for pages that already use the brand gradient */
:where(button, .btn-login, input[type="submit"])[style*="linear-gradient"],
:where(button, .btn-login, input[type="submit"])[class*="gradient"] {
  position: relative;
  overflow: hidden;
}

:where(button, .btn-login, input[type="submit"])[style*="linear-gradient"]::before,
:where(button, .btn-login, input[type="submit"])[class*="gradient"]::before {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.2);
  transition: left 0.5s ease;
}

:where(button, .btn-login, input[type="submit"])[style*="linear-gradient"]:hover::before,
:where(button, .btn-login, input[type="submit"])[class*="gradient"]:hover::before {
  left: 100%;
}

/* If a button already uses the brand gradient, give it the brand shadow on hover */
:where(button, .btn-login, input[type="submit"])[style*="#b2cd16"]:hover,
:where(button, .btn-login, input[type="submit"])[style*="#9ef755"]:hover {
  box-shadow: var(--ui-shadow-brand);
}

