/* departments/sales/includes/sales_theme.css
 * Official Savanna Fibre Sales Theme & Responsive Sidebar Controller
 * Provides clean Light Mode (default), high-contrast Dark Mode, and mobile/desktop sidebar collapse.
 */

:root {
  /* LIGHT THEME (Default) — Crisp, Clean, Modern Corporate */
  --sales-bg: #f4f6f9;
  --sales-card-bg: #ffffff;
  --sales-card-border: #e2e8f0;
  --sales-card-shadow: 0 4px 20px -2px rgba(0, 0, 0, 0.05);
  --sales-text-primary: #0f172a;
  --sales-text-secondary: #334155;
  --sales-text-muted: #64748b;
  --sales-header-bg: #ffffff;
  --sales-header-border: #e2e8f0;
  --sales-sidebar-bg: #ffffff;
  --sales-sidebar-border: #e2e8f0;
  --sales-sidebar-text: #475569;
  --sales-sidebar-hover-bg: #f8fafc;
  --sales-sidebar-hover-text: #0f172a;
  --sales-table-bg: #ffffff;
  --sales-table-th-bg: #f8fafc;
  --sales-table-th-color: #475569;
  --sales-table-border: #e2e8f0;
  --sales-table-hover: #f1f5f9;
  --sales-input-bg: #ffffff;
  --sales-input-border: #cbd5e1;
  --sales-input-color: #0f172a;
  --sales-pill-bg: #f1f5f9;
  --sales-pill-border: #e2e8f0;
  --sales-pill-color: #334155;
  --sales-dropdown-bg: #ffffff;
  --sales-dropdown-border: #e2e8f0;
  --sales-dropdown-color: #1e293b;
  --sales-dropdown-hover: #f8fafc;
  --sales-brand-orange: #F5921E;
}

/* DARK THEME — High Contrast Slate Navy (Not a pitch-black void) */
[data-theme="dark"], body.sales-theme-dark {
  --sales-bg: #0f172a;
  --sales-card-bg: #1e293b;
  --sales-card-border: rgba(255, 255, 255, 0.1);
  --sales-card-shadow: 0 8px 24px -4px rgba(0, 0, 0, 0.4);
  --sales-text-primary: #ffffff;
  --sales-text-secondary: #cbd5e1;
  --sales-text-muted: #94a3b8;
  --sales-header-bg: #111827;
  --sales-header-border: rgba(255, 255, 255, 0.08);
  --sales-sidebar-bg: #111827;
  --sales-sidebar-border: rgba(255, 255, 255, 0.08);
  --sales-sidebar-text: #cbd5e1;
  --sales-sidebar-hover-bg: rgba(255, 255, 255, 0.06);
  --sales-sidebar-hover-text: #ffffff;
  --sales-table-bg: #1e293b;
  --sales-table-th-bg: #182234;
  --sales-table-th-color: #cbd5e1;
  --sales-table-border: rgba(255, 255, 255, 0.08);
  --sales-table-hover: rgba(255, 255, 255, 0.04);
  --sales-input-bg: #182234;
  --sales-input-border: #334155;
  --sales-input-color: #ffffff;
  --sales-pill-bg: rgba(255, 255, 255, 0.06);
  --sales-pill-border: rgba(255, 255, 255, 0.08);
  --sales-pill-color: #cbd5e1;
  --sales-dropdown-bg: #1e293b;
  --sales-dropdown-border: rgba(255, 255, 255, 0.12);
  --sales-dropdown-color: #f8fafc;
  --sales-dropdown-hover: rgba(255, 255, 255, 0.08);
  --sales-brand-orange: #F5921E;
}

/* Base Body Application */
body {
  background-color: var(--sales-bg) !important;
  color: var(--sales-text-secondary) !important;
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  transition: background-color 0.25s ease, color 0.25s ease;
}

/* Top Header */
#salesTopHeader {
  background-color: var(--sales-header-bg) !important;
  border-color: var(--sales-header-border) !important;
  transition: background-color 0.25s ease, border-color 0.25s ease;
}

#salesTopHeader .sales-brand-title {
  color: var(--sales-text-primary) !important;
}

#salesTopHeader .sales-user-name {
  color: var(--sales-text-primary) !important;
}

#salesTopHeader .sales-user-role {
  color: var(--sales-text-muted) !important;
}

/* Dropdown */
.sales-dropdown-menu {
  background-color: var(--sales-dropdown-bg) !important;
  border: 1px solid var(--sales-dropdown-border) !important;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15) !important;
}

.sales-dropdown-item {
  color: var(--sales-dropdown-color) !important;
  transition: all 0.15s ease;
}

.sales-dropdown-item:hover {
  background-color: var(--sales-dropdown-hover) !important;
  color: var(--sales-brand-orange) !important;
  transform: translateX(3px);
}

/* Cards & Surfaces */
.metric-card,
.supervisor-card,
.panel-card,
.filter-box,
.action-tile,
.team-badge-card {
  background-color: var(--sales-card-bg) !important;
  border: 1px solid var(--sales-card-border) !important;
  box-shadow: var(--sales-card-shadow) !important;
  color: var(--sales-text-secondary) !important;
  border-radius: 18px;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease, background-color 0.25s ease;
}

.metric-card:hover,
.supervisor-card:hover,
.team-badge-card:hover {
  border-color: var(--sales-brand-orange) !important;
  transform: translateY(-3px);
  box-shadow: 0 12px 28px -8px rgba(245, 146, 30, 0.2) !important;
}

.action-tile {
  color: var(--sales-text-primary) !important;
}

.action-tile:hover {
  border-color: var(--sales-brand-orange) !important;
  transform: translateY(-3px);
  box-shadow: 0 12px 28px -8px rgba(245, 146, 30, 0.2) !important;
}

/* High Contrast Headings */
h1, h2, h3, h4, h5, h6,
.card-title,
.metric-value,
.supervisor-title,
.section-heading {
  color: var(--sales-text-primary);
}

/* Subtitles & Muted text */
.text-muted,
.small-muted {
  color: var(--sales-text-muted) !important;
}

/* =========================================================================
   LIGHT THEME OVERRIDES FOR PRE-EXISTING HARDCODED DARK BOOTSTRAP CLASSES
   ========================================================================= */
body:not(.sales-theme-dark) #content h1.text-white,
body:not(.sales-theme-dark) #content h2.text-white,
body:not(.sales-theme-dark) #content h3.text-white,
body:not(.sales-theme-dark) #content h4.text-white,
body:not(.sales-theme-dark) #content h5.text-white,
body:not(.sales-theme-dark) #content h6.text-white,
body:not(.sales-theme-dark) #content .metric-card .text-white,
body:not(.sales-theme-dark) #content .supervisor-card .text-white,
body:not(.sales-theme-dark) #content .panel-card .text-white,
body:not(.sales-theme-dark) #content .action-tile .text-white,
body:not(.sales-theme-dark) #content .filter-box .text-white,
body:not(.sales-theme-dark) #content .team-badge-card .text-white,
body:not(.sales-theme-dark) #content .section-title,
body:not(.sales-theme-dark) #content .d-flex > h5.text-white,
body:not(.sales-theme-dark) #content .table-dark-custom td.text-white,
body:not(.sales-theme-dark) #content .table-sales-custom td.text-white,
body:not(.sales-theme-dark) main h1.text-white,
body:not(.sales-theme-dark) main h2.text-white,
body:not(.sales-theme-dark) main h3.text-white,
body:not(.sales-theme-dark) main h4.text-white,
body:not(.sales-theme-dark) main h5.text-white,
body:not(.sales-theme-dark) main h6.text-white,
body:not(.sales-theme-dark) main .metric-card .text-white,
body:not(.sales-theme-dark) main .supervisor-card .text-white,
body:not(.sales-theme-dark) main .panel-card .text-white,
body:not(.sales-theme-dark) main .action-tile .text-white,
body:not(.sales-theme-dark) main .filter-box .text-white,
body:not(.sales-theme-dark) main .team-badge-card .text-white,
body:not(.sales-theme-dark) main .section-title,
body:not(.sales-theme-dark) main .d-flex > h5.text-white,
body:not(.sales-theme-dark) main .table-dark-custom td.text-white,
body:not(.sales-theme-dark) main .table-sales-custom td.text-white {
  color: var(--sales-text-primary, #0f172a) !important;
}

body:not(.sales-theme-dark) #content .text-white-50,
body:not(.sales-theme-dark) main .text-white-50 {
  color: var(--sales-text-muted, #64748b) !important;
}

body:not(.sales-theme-dark) #content .text-secondary,
body:not(.sales-theme-dark) main .text-secondary {
  color: var(--sales-text-muted, #64748b) !important;
}

body:not(.sales-theme-dark) #content .badge.bg-dark,
body:not(.sales-theme-dark) main .badge.bg-dark {
  background-color: #f1f5f9 !important;
  color: #334155 !important;
  border-color: #cbd5e1 !important;
}

body:not(.sales-theme-dark) #content .panel-card {
  background: #ffffff !important;
  border: 1px solid #eef0f4 !important;
  box-shadow: 0 2px 6px rgba(0,0,0,0.03) !important;
  color: #1e293b !important;
}

/* Tables */
.table-dark-custom,
.table-sales-custom,
table.sales-table {
  --bs-table-bg: transparent;
  color: var(--sales-text-secondary) !important;
  border-color: var(--sales-table-border) !important;
}

.table-dark-custom th,
.table-sales-custom th,
table.sales-table th {
  background-color: var(--sales-table-th-bg) !important;
  color: var(--sales-table-th-color) !important;
  border-bottom: 2px solid var(--sales-table-border) !important;
  font-weight: 700 !important;
  font-size: 0.76rem !important;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.table-dark-custom td,
.table-sales-custom td,
table.sales-table td {
  background-color: var(--sales-table-bg) !important;
  color: var(--sales-text-secondary) !important;
  border-bottom: 1px solid var(--sales-table-border) !important;
  vertical-align: middle;
}

.table-dark-custom tr:hover td,
.table-sales-custom tr:hover td,
table.sales-table tr:hover td {
  background-color: var(--sales-table-hover) !important;
}

/* Form Controls & Inputs */
.form-control,
.form-select,
.form-control-custom {
  background-color: var(--sales-input-bg) !important;
  border: 1px solid var(--sales-input-border) !important;
  color: var(--sales-input-color) !important;
}

.form-control:focus,
.form-select:focus,
.form-control-custom:focus {
  border-color: var(--sales-brand-orange) !important;
  box-shadow: 0 0 0 0.2rem rgba(245, 146, 30, 0.2) !important;
}

/* Navigation Tabs */
.nav-tab-custom .nav-link {
  color: var(--sales-text-muted) !important;
  border: 1px solid var(--sales-card-border) !important;
  background-color: var(--sales-card-bg) !important;
  border-radius: 12px;
  padding: 0.65rem 1.25rem;
  font-weight: 700;
  font-size: 0.88rem;
  transition: all 0.2s ease;
}

.nav-tab-custom .nav-link:hover {
  color: var(--sales-text-primary) !important;
  border-color: var(--sales-brand-orange) !important;
}

.nav-tab-custom .nav-link.active {
  background-color: var(--sales-brand-orange) !important;
  color: #000000 !important;
  font-weight: 800 !important;
  border-color: var(--sales-brand-orange) !important;
  box-shadow: 0 4px 14px rgba(245, 146, 30, 0.35) !important;
}

/* Pills & Badges */
.agent-pill {
  background-color: var(--sales-pill-bg) !important;
  border: 1px solid var(--sales-pill-border) !important;
  color: var(--sales-pill-color) !important;
  border-radius: 12px;
  padding: 0.65rem 0.85rem;
  transition: all 0.15s ease;
}

.agent-pill:hover {
  border-color: var(--sales-brand-orange) !important;
  transform: translateY(-1px);
}

.kpi-mini-card {
  background-color: var(--sales-pill-bg) !important;
  border: 1px solid var(--sales-pill-border) !important;
  color: var(--sales-pill-color) !important;
  border-radius: 12px;
  padding: 0.75rem 1rem;
}

.btn-brand-orange {
  background-color: var(--sales-brand-orange) !important;
  color: #000000 !important;
  font-weight: 700 !important;
  border: none !important;
  transition: all 0.2s ease;
}

.btn-brand-orange:hover {
  background-color: #e08316 !important;
  color: #000000 !important;
  transform: translateY(-1px);
}

.sup-nav-item {
  background-color: var(--sales-card-bg) !important;
  border: 1px solid var(--sales-card-border) !important;
  border-radius: 14px;
  padding: 1rem 1.25rem;
  text-decoration: none;
  color: var(--sales-text-secondary) !important;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: all 0.2s ease;
}

.sup-nav-item:hover, .sup-nav-item.active {
  background-color: var(--sales-pill-bg) !important;
  border-color: var(--sales-brand-orange) !important;
  color: var(--sales-text-primary) !important;
  transform: translateX(4px);
}

.badge-rank-1 { background: linear-gradient(135deg, #F5921E, #FBBF24) !important; color: #000000 !important; font-weight: 800; }
.badge-rank-2 { background: linear-gradient(135deg, #94A3B8, #E2E8F0) !important; color: #000000 !important; font-weight: 800; }
.badge-rank-3 { background: linear-gradient(135deg, #B45309, #F59E0B) !important; color: #ffffff !important; font-weight: 800; }
.badge-rank-4, .badge-rank-other { background: var(--sales-pill-bg) !important; color: var(--sales-text-secondary) !important; border: 1px solid var(--sales-pill-border) !important; font-weight: 700; }

/* Modals */
.modal-content {
  background-color: var(--sales-card-bg) !important;
  color: var(--sales-text-primary) !important;
  border: 1px solid var(--sales-card-border) !important;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3) !important;
}

.modal-header,
.modal-footer {
  border-color: var(--sales-card-border) !important;
}

/* =========================================================================
   SIDEBAR TOGGLE & RESPONSIVE DRAWER SYSTEM (PC & MOBILE)
   ========================================================================= */

#salesSidebar {
  background-color: var(--sales-sidebar-bg) !important;
  border-right: 1px solid var(--sales-sidebar-border) !important;
  transition: width 0.25s ease, margin-left 0.25s ease, transform 0.28s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.2s ease;
  flex-shrink: 0;
}

#salesSidebar .sales-nav-link {
  color: var(--sales-sidebar-text) !important;
  font-weight: 600;
  transition: all 0.18s ease;
}

#salesSidebar .sales-nav-link:hover {
  background-color: var(--sales-sidebar-hover-bg) !important;
  color: var(--sales-sidebar-hover-text) !important;
  transform: translateX(2px);
}

#salesSidebar .active-brand {
  background-color: var(--sales-brand-orange) !important;
  color: #000000 !important;
  font-weight: 800 !important;
  box-shadow: 0 4px 14px rgba(245, 146, 30, 0.35) !important;
}

/* Tribal strip */
.sales-tribal-strip {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: 8px;
  background-image: url('/nexus/assets/savanna_tribal_pattern.svg');
  background-size: 24px 32px;
  background-repeat: repeat-y;
  border-right: 1px solid rgba(0, 0, 0, 0.15);
  z-index: 2;
}

/* Desktop Mode (>= 992px) */
@media (min-width: 992px) {
  #salesSidebar {
    width: 270px;
    min-width: 270px;
    min-height: calc(100vh - 63px);
    display: block !important;
  }

  /* When collapsed on desktop */
  body.sales-sidebar-collapsed #salesSidebar {
    width: 0 !important;
    min-width: 0 !important;
    margin-left: -270px !important;
    opacity: 0 !important;
    pointer-events: none !important;
    overflow: hidden !important;
    border: none !important;
  }

  /* Main content expands to fill available width */
  main {
    transition: width 0.25s ease, max-width 0.25s ease;
  }
  
  body.sales-sidebar-collapsed main {
    max-width: 100% !important;
  }
}

/* Mobile & Tablet Mode (< 992px) */
@media (max-width: 991.98px) {
  #salesSidebar {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    bottom: 0 !important;
    width: 285px !important;
    max-width: 86vw !important;
    z-index: 1055 !important;
    height: 100vh !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    transform: translateX(-100%);
    box-shadow: none;
    margin-left: 0 !important;
    display: block !important;
  }

  body.sales-sidebar-open #salesSidebar {
    transform: translateX(0) !important;
    box-shadow: 12px 0 40px rgba(0, 0, 0, 0.45) !important;
  }

  #salesSidebarBackdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 1050;
    opacity: 0;
    transition: opacity 0.25s ease;
  }

  body.sales-sidebar-open #salesSidebarBackdrop {
    display: block !important;
    opacity: 1 !important;
  }

  body.sales-sidebar-open {
    overflow: hidden !important;
  }
}

/* Hamburger & Toggle Buttons */
.sales-toggle-btn {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(245, 146, 30, 0.1);
  border: 1px solid rgba(245, 146, 30, 0.3) !important;
  color: var(--sales-brand-orange) !important;
  cursor: pointer;
  transition: all 0.18s ease;
}

.sales-toggle-btn:hover {
  background: var(--sales-brand-orange) !important;
  color: #000000 !important;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(245, 146, 30, 0.3);
}

.sales-theme-btn {
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 700;
  transition: all 0.2s ease;
}
