/* ═══════════════════════════════════════════════════════════════════════════
   lte_CrmSetting.css  —  Y5 CRM Settings, Theme & Accessibility Styles  v2.0
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── CSS Custom Properties ─────────────────────────────────────────────────── */
:root {
  --y5-accent: #0d6efd;
  --y5-font-size: 1rem;
}

/* ── Theme Colour Overrides ────────────────────────────────────────────────── */
body.theme-blue   { --y5-accent: #0d6efd; }
body.theme-green  { --y5-accent: #198754; }
body.theme-purple { --y5-accent: #6f42c1; }
body.theme-orange { --y5-accent: #fd7e14; }
body.theme-red    { --y5-accent: #dc3545; }
body.theme-teal   { --y5-accent: #20c997; }
body.theme-indigo { --y5-accent: #6610f2; }
body.theme-pink   { --y5-accent: #d63384; }
body.theme-dark   { --y5-accent: #343a40; }
body.theme-cyan   { --y5-accent: #0dcaf0; }

/* Apply accent to key UI elements */
.main-header.navbar {
  border-bottom-color: var(--y5-accent) !important;
}

.main-header.navbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.main-header .navbar-nav {
  display: flex;
  align-items: center;
}

.navbar-nav-left {
  flex: 1 1 auto;
  min-width: 0;
  gap: 0.75rem;
}

.navbar-nav-actions {
  flex: 0 0 auto;
}

.nav-menu-toggle {
  width: 2.5rem;
  height: 2.5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 0.85rem;
  border: 1px solid rgba(13, 110, 253, 0.16);
  background: rgba(13, 110, 253, 0.08);
}

.nav-menu-toggle:hover,
.nav-menu-toggle:focus {
  background: rgba(13, 110, 253, 0.14);
}
#settingsSidebar .form-check-input:checked {
  background-color: var(--y5-accent);
  border-color: var(--y5-accent);
}
#settingsSidebar .form-select:focus {
  border-color: var(--y5-accent);
  box-shadow: 0 0 0 0.15rem rgba(var(--y5-accent), 0.25);
}
.form-check-input:checked + .form-check-label .toggle-icon {
  color: var(--y5-accent) !important;
}


/* ══════════════════════════════════════════════════════════════════════════════
   FONT FAMILIES
   ══════════════════════════════════════════════════════════════════════════════ */
body.font-default {
  font-family: 'Inter', 'Roboto', 'Helvetica Neue', Arial, sans-serif !important;
  letter-spacing: 0.2px;
}
body.font-monospace {
  font-family: 'Courier New', Courier, monospace;
  letter-spacing: 0.2px;
}
body.font-serif {
  font-family: 'Source Sans Pro', 'Helvetica Neue', Arial, sans-serif;
  letter-spacing: 0.2px;
}
body.font-georgia {
  font-family: Georgia, 'Times New Roman', serif;
  letter-spacing: 0.2px;
}
body.font-poppins {
  font-family: 'Poppins', 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
  letter-spacing: 0.2px;
}
body.font-montserrat {
  font-family: 'Montserrat', 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
  letter-spacing: 0.2px;
}
body.font-roboto {
  font-family: 'Roboto', 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
  letter-spacing: 0.2px;
}
body.font-lato {
  font-family: 'Lato', 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
  letter-spacing: 0.2px;
}
body.font-cursive {
  font-family: cursive, 'Comic Sans MS', 'Apple Chancery', sans-serif;
  letter-spacing: 0.2px;
}

/* 繁體字體 */
body.font-noto-tc    { font-family: 'Noto Sans TC', sans-serif; }
body.font-cwtex-kai  { font-family: 'cwTeX Kai', serif; }
body.font-cwtex-ming { font-family: 'cwTeX Ming', serif; }
body.font-pingfang   { font-family: 'PingFang TC', sans-serif; }
body.font-pmingliu   { font-family: 'PMingLiU', serif; }

/* 簡體字體 */
body.font-noto-sc  { font-family: 'Noto Sans SC', sans-serif; }
body.font-dengxian  { font-family: 'DengXian', sans-serif; }
body.font-yahei     { font-family: 'Microsoft YaHei', sans-serif; }
body.font-simhei    { font-family: 'SimHei', sans-serif; }
body.font-simsun    { font-family: 'SimSun', serif; }
body.font-fangsong  { font-family: 'FangSong', serif; }


/* ══════════════════════════════════════════════════════════════════════════════
   TEXT SIZE (via CSS variable — composes with view_mode)
   ══════════════════════════════════════════════════════════════════════════════ */
body {
  font-size: var(--y5-font-size, 1rem);
}


/* ══════════════════════════════════════════════════════════════════════════════
   NAVBAR BOTTOM LINE — per-module colour accents
   ══════════════════════════════════════════════════════════════════════════════ */
.navbar-bottom-line {
  border-bottom: 2px solid var(--y5-accent, #EC0B0B);
}

.LTE_CASHIER_AGENT_navbar-bottom-line { border-bottom: 2px solid #A8E6A1; }
.LTE_BILLING_navbar-bottom-line       { border-bottom: 2px solid #F28B82; }
.LTE_BILLING_2_navbar-bottom-line     { border-bottom: 2px solid #FBBC04; }
.LTE_BOOKING_PLAN_navbar-bottom-line  { border-bottom: 2px solid #34A853; }
.LTE_CREATE_INV_navbar-bottom-line    { border-bottom: 2px solid #42A5F5; }
.LTE_CREATE_PO_navbar-bottom-line     { border-bottom: 2px solid #AB47BC; }
.LTE_CREATE_SO_navbar-bottom-line     { border-bottom: 2px solid #26C6DA; }

.LTE_CRM_CONSIGNEE_DASHBOARD_navbar-bottom-line  { border-bottom: 2px solid #FFA726; }
.LTE_CRM_MY_CENTER_AGENT_navbar-bottom-line      { border-bottom: 2px solid #8D6E63; }
.LTE_CRM_MY_CENTER_CONSIGNEE_navbar-bottom-line  { border-bottom: 2px solid #5C6BC0; }

.LTE_PO_CENTER_navbar-bottom-line  { border-bottom: 2px solid #A8E6A1; }
.LTE_SO_CENTER_navbar-bottom-line  { border-bottom: 2px solid #ADD8E6; }
.LTE_INV_CENTER_navbar-bottom-line { border-bottom: 2px solid #003366; }


/* ══════════════════════════════════════════════════════════════════════════════
   VIEW MODES  (cozy / compact / comfortable)
   Scale relative to --y5-font-size so user text-size pref composes correctly.
   ══════════════════════════════════════════════════════════════════════════════ */
body.view-cozy       { font-size: var(--y5-font-size, 1rem); }
body.view-compact    { font-size: calc(var(--y5-font-size, 1rem) * 0.85); }
body.view-comfortable { font-size: calc(var(--y5-font-size, 1rem) * 1.25); }


/* ══════════════════════════════════════════════════════════════════════════════
   DARK MODE — Navbar
   ══════════════════════════════════════════════════════════════════════════════ */
body.dark-mode .main-header.navbar {
  background-color: #454d55;
  color: #f1f1f1;
  border-bottom: 1px solid #444;
}


/* ══════════════════════════════════════════════════════════════════════════════
   SETTINGS SIDEBAR
   FIX: removed "display: none" — was blocking the CSS right-transition.
        Now uses visibility + right offset for a smooth slide-in.
   ══════════════════════════════════════════════════════════════════════════════ */
#settingsSidebar {
  width: 300px;
  height: 100vh;
  z-index: 1050;
  background: #fff;
  box-shadow: -4px 0 20px rgba(0, 0, 0, 0.12);
  border-left: 1px solid #e0e0e0;
  position: fixed;
  top: 0;
  right: -320px;
  transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1),
              visibility 0.3s;
  overflow-y: auto;
  visibility: hidden;
}

#settingsSidebar.open {
  right: 0;
  visibility: visible;
}

.setting_label_switch {
  margin-left: 1.5rem;
}

.setting_label_switch label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Divider between sidebar sections */
.settings-divider {
  border: 0;
  border-top: 1px solid #dee2e6;
  margin: 1rem 0;
}


/* ══════════════════════════════════════════════════════════════════════════════
   THEME COLOUR SWATCHES
   ══════════════════════════════════════════════════════════════════════════════ */
.theme-swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.theme-swatch {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 2px solid #dee2e6;
  cursor: pointer;
  padding: 0;
  transition: transform 0.15s, box-shadow 0.15s;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0;
  line-height: 1;
}

/* Colour backgrounds — matches THEME_COLORS in crm_app.js */
.theme-swatch[data-theme="blue"]   { background: #0d6efd; }
.theme-swatch[data-theme="green"]  { background: #198754; }
.theme-swatch[data-theme="purple"] { background: #6f42c1; }
.theme-swatch[data-theme="orange"] { background: #fd7e14; }
.theme-swatch[data-theme="red"]    { background: #dc3545; }
.theme-swatch[data-theme="teal"]   { background: #20c997; }
.theme-swatch[data-theme="indigo"] { background: #6610f2; }
.theme-swatch[data-theme="pink"]   { background: #d63384; }

.theme-swatch.active {
  transform: scale(1.15);
  box-shadow: 0 0 0 3px #fff, 0 0 0 5px var(--y5-accent, #0d6efd);
}

.theme-swatch:hover {
  transform: scale(1.1);
}

/* Reset button */
.theme-swatch--reset {
  background: #f8f9fa;
  color: #6c757d;
  font-size: 14px;
  border: 2px dashed #ced4da;
}
.theme-swatch--reset i {
  font-size: 14px;
}
.theme-swatch--reset:hover {
  background: #e9ecef;
}


/* ══════════════════════════════════════════════════════════════════════════════
   HOVER DROPDOWN SUPPORT
   ══════════════════════════════════════════════════════════════════════════════ */
.dropdown-hover:hover .dropdown-menu {
  display: block;
  margin-top: 0;
}


/* ══════════════════════════════════════════════════════════════════════════════
   SWITCH / TOGGLE ICON FEEDBACK
   ══════════════════════════════════════════════════════════════════════════════ */
.toggle-icon {
  color: #6c757d;
  transition: color 0.2s ease;
}


/* ══════════════════════════════════════════════════════════════════════════════
   RESPONSIVE
   ══════════════════════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  #settingsSidebar {
    width: 100%;
    right: -100%;
  }
  #settingsSidebar.open {
    right: 0;
  }
}


/* ══════════════════════════════════════════════════════════════════════════════
   DARK MODE  — General UI
   FIX: class name is "dark-mode" (hyphen) not "dark_mode" (underscore)
   ══════════════════════════════════════════════════════════════════════════════ */
body.dark-mode a {
  color: #90caf9;
}
body.dark-mode a:hover {
  color: #64b5f6;
}

body.dark-mode .card,
body.dark-mode .dropdown-menu,
body.dark-mode #settingsSidebar {
  background-color: #1e1e1e;
  color: #e0e0e0;
  border-color: #333;
  box-shadow: none;
}

body.dark-mode #settingsSidebar {
  border-left: 1px solid #333;
}

/* Tabs */
body.dark-mode .nav-tabs .nav-link {
  background-color: transparent;
  border-color: #333;
  color: #ccc;
}
body.dark-mode .nav-tabs .nav-link.active {
  background-color: #2c2c2c;
  color: #fff;
  border-color: #444 #444 #2c2c2c;
}

/* Tables */
body.dark-mode table {
  background-color: #1e1e1e;
  color: #e0e0e0;
}
body.dark-mode .btn-close {
  color: #f1f1f1;
}
body.dark-mode table thead {
  background-color: #2a2a2a;
  color: #f1f1f1;
}
body.dark-mode table tbody tr:nth-child(even) {
  background-color: #2c2c2c;
}

/* Toggle icons */
body.dark-mode .toggle-icon {
  color: #bbb;
}

/* Scrollbars (WebKit) */
body.dark-mode ::-webkit-scrollbar { width: 10px; }
body.dark-mode ::-webkit-scrollbar-track { background: #1a1a1a; }
body.dark-mode ::-webkit-scrollbar-thumb { background: #444; border-radius: 4px; }
body.dark-mode ::-webkit-scrollbar-thumb:hover { background: #666; }

/* Theme swatches in dark mode */
body.dark-mode .theme-swatch {
  border-color: #555;
}
body.dark-mode .theme-swatch.active {
  box-shadow: 0 0 0 3px #1e1e1e, 0 0 0 5px var(--y5-accent, #0d6efd);
}
body.dark-mode .theme-swatch--reset {
  background: #2c2c2c;
  color: #aaa;
  border-color: #555;
}
body.dark-mode .settings-divider {
  border-top-color: #444;
}

/* Close button in dark mode */
body.dark-mode .btn-close_setting {
  background: transparent url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23fff'%3e%3cpath d='M.146.146a.5.5 0 0 1 .708 0L8 7.293l7.146-7.147a.5.5 0 0 1 .708.708L8.707 8l7.147 7.146a.5.5 0 0 1-.708.708L8 8.707l-7.146 7.147a.5.5 0 0 1-.708-.708L7.293 8 .146.854a.5.5 0 0 1 0-.708z'/%3e%3c/svg%3e") center/1em auto no-repeat;
}


/* ══════════════════════════════════════════════════════════════════════════════
   HIGH CONTRAST BUTTONS
   ══════════════════════════════════════════════════════════════════════════════ */
.high-contrast-buttons .btn {
  background-color: #000 !important;
  color: #fff !important;
  border: 2px solid #fff !important;
}
.high-contrast-buttons .btn:hover {
  background-color: #fff !important;
  color: #000 !important;
  border-color: #000 !important;
}


/* ══════════════════════════════════════════════════════════════════════════════
   BIG CURSOR
   ══════════════════════════════════════════════════════════════════════════════ */
.big-cursor,
.big-cursor * {
  cursor: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 24 24"><path d="M5 3l14 8-6.5 1.5L11 19z" fill="%23000" stroke="%23fff" stroke-width="1.5"/></svg>') 4 2, auto !important;
}

body.dark-mode.big-cursor,
body.dark-mode.big-cursor * {
  cursor: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 24 24"><path d="M5 3l14 8-6.5 1.5L11 19z" fill="%23fff" stroke="%23000" stroke-width="1.5"/></svg>') 4 2, auto !important;
}


/* ══════════════════════════════════════════════════════════════════════════════
   READING MASK  — darkens top & bottom of viewport around cursor strip
   Heights are set via --mask-top / --mask-bottom CSS vars from crm_app.js
   ══════════════════════════════════════════════════════════════════════════════ */
#reading-mask-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 9999;
  display: none;
}

#reading-mask-overlay::before,
#reading-mask-overlay::after {
  content: '';
  position: fixed;
  left: 0;
  width: 100%;
  background-color: rgba(0, 0, 0, 0.6);
  z-index: 9999;
  transition: height 0.05s linear;
}

#reading-mask-overlay::before {
  top: 0;
  height: var(--mask-top, 40%);
}

#reading-mask-overlay::after {
  bottom: 0;
  height: var(--mask-bottom, 40%);
}

body.reading-mask-active #reading-mask-overlay {
  display: block;
}


/* ══════════════════════════════════════════════════════════════════════════════
   READING GUIDE LINE  — horizontal line following cursor
   Position set via style.top from crm_app.js
   ══════════════════════════════════════════════════════════════════════════════ */
#reading-guide-line {
  position: fixed;
  width: 100%;
  height: 2px;
  background: linear-gradient(90deg, transparent, #ff4444, transparent);
  top: 50%;
  left: 0;
  pointer-events: none;
  z-index: 9999;
  display: none;
  box-shadow: 0 0 6px rgba(255, 68, 68, 0.4);
}

body.reading-guide-active #reading-guide-line {
  display: block;
}


/* ══════════════════════════════════════════════════════════════════════════════
   FOCUS HIGHLIGHT  — outlines on :focus and :hover for keyboard/pointer users
   ══════════════════════════════════════════════════════════════════════════════ */
body.focus-highlight *:focus {
  outline: 3px solid var(--y5-accent, #0d6efd) !important;
  outline-offset: 2px !important;
}

body.focus-highlight a:hover,
body.focus-highlight button:hover,
body.focus-highlight [role="button"]:hover,
body.focus-highlight input:hover,
body.focus-highlight select:hover,
body.focus-highlight textarea:hover {
  outline: 2px dashed var(--y5-accent, #0d6efd) !important;
  outline-offset: 2px !important;
}


/* ══════════════════════════════════════════════════════════════════════════════
   REDUCE MOTION  — disables animations & transitions globally
   ══════════════════════════════════════════════════════════════════════════════ */
body.reduce-motion *,
body.reduce-motion *::before,
body.reduce-motion *::after {
  animation-duration:        0.01ms !important;
  animation-iteration-count: 1 !important;
  transition-duration:       0.01ms !important;
  scroll-behavior:           auto !important;
}


/* ══════════════════════════════════════════════════════════════════════════════
   CLOSE BUTTON  (settings sidebar)
   ══════════════════════════════════════════════════════════════════════════════ */
.btn-close_setting {
  background: transparent url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23000'%3e%3cpath d='M.146.146a.5.5 0 0 1 .708 0L8 7.293l7.146-7.147a.5.5 0 0 1 .708.708L8.707 8l7.147 7.146a.5.5 0 0 1-.708.708L8 8.707l-7.146 7.147a.5.5 0 0 1-.708-.708L7.293 8 .146.854a.5.5 0 0 1 0-.708z'/%3e%3c/svg%3e") center/1em auto no-repeat;
  border: none;
  width: 1em;
  height: 1em;
  opacity: 0.5;
  cursor: pointer;
}
.btn-close_setting:hover {
  opacity: 0.75;
}

  /* ---------------------------------------------------
   FIXED MAIN LOGO (large screens no shrink)
  --------------------------------------------------- */
  #mainLogo {
    height: 58px;
    max-width: 360px;
    object-fit: contain;
  }

  @media (max-width: 576px) {
    #mainLogo {
      height: 32px;
      max-width: 120px;
    }
  }

  /* ---------------------------------------------------
   LEFT NAV - HAMBURGER
  --------------------------------------------------- */
  .navbar-nav .mobile-hamburger {
    display: none;
  }

  @media (max-width: 768px) {
    .navbar-nav .mobile-hamburger {
      display: flex;
      align-items: center;
    }
  }

  /* ---------------------------------------------------
   RIGHT NAV — ICON & PROFILE ALWAYS SAME ROW
  --------------------------------------------------- */
  .navbar-nav.ml-auto {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: nowrap !important;
    white-space: nowrap;
  }

  .profile-menu {
    display: flex;
    align-items: center;
  }

  /* Profile section */
  #profileDropdown img {
    width: 40px;
    height: 40px;
  }

  @media (max-width: 768px) {
    .main-header.navbar {
      gap: 0.5rem;
      padding-inline: 0.75rem;
    }

    .navbar-nav-left {
      gap: 0.5rem;
      min-width: 0;
    }

    .navbar-nav-actions {
      gap: 0.35rem;
    }

    .nav-menu-toggle {
      width: 2.35rem;
      height: 2.35rem;
      padding: 0;
      font-size: 1rem;
    }

    .nav-item-session,
    #idleStatusBar {
      display: none !important;
    }

    #mainLogo {
      max-width: 140px;
      flex: 0 1 auto;
    }

    #profileDropdown span {
      display: none;
    }

    #profileDropdown img {
      width: 32px;
      height: 32px;
    }
  }

  /* ---------------------------------------------------
   IDLE TIMER CHIP
  --------------------------------------------------- */
  .idle-timer-chip {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: rgba(255, 255, 255, 0.06);
    backdrop-filter: blur(10px);
    border-radius: 10px;
    height: 28px;
  }

  .idle-icon i {
    font-size: 12px;
    color: #00eaff;
  }

  .idle-time {
    font-size: 12px;
    min-width: 60px;
    text-align: center;
    font-weight: 600;
  }

  .idle-progress-nav {
    width: 45px;
    height: 3px;
    border-radius: 3px;
    overflow: hidden;
  }

  #idleProgressFill {
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, #00eaff, #4CAF50, #FFC107, #ff3d3d);
    background-size: 300% 100%;
    animation: gradientFlow 6s linear infinite;
  }

  @keyframes gradientFlow {
    0% {
      background-position: 0% 0%;
    }

    100% {
      background-position: 300% 0%;
    }
  }

  @media (max-width: 430px) {
    .main-header.navbar {
      padding-inline: 0.5rem;
    }

    #darkModeToggle,
    #full_screenToggle {
      padding-inline: 0.5rem;
    }

    #mainLogo {
      max-width: 104px;
    }

    .idle-timer-chip {
      padding: 3px 6px;
      gap: 4px;
      height: 24px;
    }

    .idle-icon {
      display: none;
    }

    .idle-time {
      min-width: 46px;
      font-size: 11px;
    }

    .idle-progress-nav {
      width: 36px;
      height: 3px;
    }
  }

  body.dark-mode .idle-timer-chip {
    box-shadow: 0 0 10px rgba(0, 234, 255, 0.2);
  }

  /* ---------------------------------------------------
   SIDEBAR ICON MODE (emoji / fa)
  --------------------------------------------------- */
  .main-sidebar[data-icon-type="emoji"] .nav-link .emoji {
    display: inline-block !important;
  }

  .main-sidebar[data-icon-type="emoji"] .nav-link .fa-icon {
    display: none !important;
  }

  .main-sidebar[data-icon-type="fa"] .nav-link .fa-icon {
    display: inline-block !important;
  }

  .main-sidebar[data-icon-type="fa"] .nav-link .emoji {
    display: none !important;
  }

  .main-sidebar[data-icon-type="fa"] .nav-item>.nav-link:hover .emoji,
  .main-sidebar[data-icon-type="fa"] .nav-item>.nav-link.active .emoji,
  .main-sidebar[data-icon-type="fa"] .nav-item.has-treeview>.nav-link:hover .emoji,
  .main-sidebar[data-icon-type="fa"] .nav-item.has-treeview>.nav-link.active .emoji {
    display: none !important;
  }

  .main-sidebar[data-icon-type="emoji"] .nav-item>.nav-link:hover .fa-icon,
  .main-sidebar[data-icon-type="emoji"] .nav-item>.nav-link.active .fa-icon,
  .main-sidebar[data-icon-type="emoji"] .nav-item.has-treeview>.nav-link:hover .fa-icon,
  .main-sidebar[data-icon-type="emoji"] .nav-item.has-treeview>.nav-link.active .fa-icon {
    display: none !important;
  }
