/* ============================================================
   Elite Recycling Solutions — Control MVP
   Custom CSS — Bootstrap 4.1 extension layer
   ============================================================ */

:root {
  /* Brand colours — Elite Recycling Solutions */
  --elite-green:         #27ae60;   /* kept for success states / badges */
  --elite-green-dark:    #1a4a2d;   /* navbar + sidebar + primary buttons */
  --elite-green-mid:     #245c35;   /* sidebar hover */
  --elite-orange:        #f08801;   /* accent: active links, navbar border, CTAs */
  --elite-orange-lite:   rgba(240,136,1,.12);
  --elite-navy:          #1a4a2d;   /* legacy alias → forest green */
  --elite-sidebar-bg:    #1a4a2d;
  --elite-sidebar-hover: #245c35;
  --elite-body-bg:       #f5f7f5;   /* very light green-grey */
  --elite-card-radius:   6px;
}

/* ── Body & Layout ──────────────────────────────────────────── */
body.elite-body {
  background-color: var(--elite-body-bg);
  font-size: 0.88rem;
}

.elite-main {
  margin-top: 60px;        /* below fixed navbar (60px tall) */
  margin-left: 215px;      /* beside expanded sidebar */
  padding-bottom: 2rem;
  min-height: calc(100vh - 60px);
  /* Fill remaining width in Bootstrap .row flex container */
  flex: 1 1 0%;
  min-width: 0;
  max-width: 100%;
  width: 100%;
  box-sizing: border-box;
}

.elite-footer {
  margin-left: 215px;
}

/* ── Layout wrapper: neutralise Bootstrap row negative margins ── */
/* The sidebar is position:fixed so .row only contains <main>.    */
/* Without this, Bootstrap's flex row clips the main to ~col width */
.container-fluid > .row {
  margin-left: 0;
  margin-right: 0;
  flex-wrap: nowrap;
}

/* ── App-wide copyright footer ───────────────────────────────── */
.elite-footer {
  padding: .55rem 1.5rem;
  font-size: .75rem;
  color: #6c757d;
  border-top: 1px solid #dee2e6;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.elite-footer a {
  color: var(--elite-orange);
  text-decoration: none;
}

.elite-footer a:hover {
  text-decoration: underline;
}

/* ── Navbar ─────────────────────────────────────────────────── */
.elite-navbar {
  background: var(--elite-green-dark) !important;
  height: 60px;
  border-bottom: 3px solid var(--elite-orange);
  box-shadow: 0 2px 8px rgba(0,0,0,.25);
}

.elite-navbar .navbar-brand {
  font-size: 1.1rem;
  letter-spacing: 0.02em;
  color: #fff !important;
  padding: 0;
}

.elite-navbar .navbar-brand svg {
  height: 38px;
  width: auto;
}

.elite-navbar .navbar-text,
.elite-navbar .nav-link {
  color: #b8d4c0 !important;
}

.elite-navbar .badge-light {
  background: var(--elite-orange);
  color: #fff;
}

/* ── Sidebar ─────────────────────────────────────────────────── */
.elite-sidebar {
  position: fixed;
  top: 60px;
  bottom: 0;
  left: 0;
  background: var(--elite-sidebar-bg);
  overflow-y: auto;
  z-index: 100;
  padding-top: 0.5rem;
  box-shadow: 2px 0 5px rgba(0,0,0,0.15);
}

.elite-sidebar .sidebar-sticky {
  padding: 0.5rem 0;
}

.sidebar-section-label {
  padding: 0.5rem 1rem 0.25rem;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #7f8c8d;
}

.elite-sidebar .nav-link {
  color: #bdc3c7;
  padding: 0.45rem 1rem;
  font-size: 0.85rem;
  border-radius: 0;
  transition: background 0.15s, color 0.15s;
  display: flex;
  align-items: center;
}

.elite-sidebar .nav-link:hover {
  background: var(--elite-green-mid);
  color: #fff;
  text-decoration: none;
}

.elite-sidebar .nav-link.active {
  border-left: 3px solid var(--elite-orange);
  background: var(--elite-orange-lite);
  color: #f5dba8;
  font-weight: 600;
}

.elite-sidebar .nav-link i {
  width: 18px;
  text-align: center;
}

.sidebar-badge {
  margin-left: auto;
  font-size: 0.65rem;
}

/* ── Login ───────────────────────────────────────────────────── */
body.elite-login-body {
  min-height: 100vh;
  background: var(--elite-body-bg);
}

.elite-login-brand {
  background: linear-gradient(135deg, var(--elite-green-dark) 0%, #2d6a3f 100%);
  min-height: 100vh;
}

.login-icon {
  filter: drop-shadow(0 4px 16px rgba(39,174,96,0.5));
  animation: pulse-icon 3s ease-in-out infinite;
}

@keyframes pulse-icon {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.85; transform: scale(1.04); }
}

/* ── KPI Cards ───────────────────────────────────────────────── */
.elite-kpi-card {
  border-radius: var(--elite-card-radius);
  border: 0;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

.border-left-success  { border-left: 4px solid var(--elite-green) !important; }
.border-left-warning  { border-left: 4px solid var(--elite-orange) !important; }
.border-left-danger   { border-left: 4px solid #e74c3c !important; }
.border-left-primary  { border-left: 4px solid #2980b9 !important; }
.border-left-info     { border-left: 4px solid #16a085 !important; }
.border-left-orange   { border-left: 4px solid #e67e22 !important; }
.border-left-dark-danger { border-left: 4px solid #8e0000 !important; }

.text-xs {
  font-size: 0.72rem;
}

/* ── KPI Cards — fixed uniform size ─────────────────────────── */
/*
  All 6 dashboard KPI cards are identical in dimensions:
  - Fixed height so sub-labels don't shift height between cards
  - Fixed number font-size (1.85rem) — handles 1–9999 without overflow
  - Icon is decorative overlay, never affects layout
*/
.kpi-card-body {
  height: 96px;              /* fixed — same for every card */
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 0 1rem;
  position: relative;
  overflow: hidden;
}

.kpi-card-icon {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 2rem;
  opacity: 0.12;
  pointer-events: none;
  line-height: 1;
}

.kpi-card-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: #6c757d;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 4px;
}

.kpi-card-value {
  font-size: 1.85rem;    /* fits 4 digits comfortably; shrinks slightly on small screens */
  font-weight: 700;
  line-height: 1;
  margin-bottom: 4px;
  font-variant-numeric: tabular-nums; /* monospace digits — no layout jump between 1 and 9999 */
}

.kpi-card-sub {
  font-size: 0.72rem;
  color: #6c757d;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-height: 1em;       /* always reserve 1 line even if empty — keeps height identical */
}

/* ── Cards ───────────────────────────────────────────────────── */
.card {
  border-radius: var(--elite-card-radius);
  border: 1px solid rgba(0,0,0,0.06);
}

.card-header {
  background: #fff;
  border-bottom: 1px solid rgba(0,0,0,0.08);
  font-size: 0.88rem;
  padding: 0.65rem 1rem;
}

/* ── Tables ──────────────────────────────────────────────────── */
.table-sm td, .table-sm th {
  padding: 0.35rem 0.5rem;
  vertical-align: middle;
}

.table-hover tbody tr:hover {
  background-color: rgba(39,174,96,0.04);
}

/* ── Buttons ─────────────────────────────────────────────────── */
.btn-xs {
  padding: 0.1rem 0.4rem;
  font-size: 0.75rem;
}

.btn-success, .btn-primary {
  border-radius: 4px;
}

/* ── Badges ──────────────────────────────────────────────────── */
.badge {
  font-size: 0.72rem;
  letter-spacing: 0.02em;
}

/* ── Utility ─────────────────────────────────────────────────── */
.font-weight-semibold { font-weight: 600; }

.opacity-50 { opacity: 0.5; }

/* ── Progress bars ───────────────────────────────────────────── */
.progress {
  border-radius: 10px;
}
.progress-bar {
  font-size: 0.72rem;
  font-weight: 700;
}

/* ═══════════════════════════════════════════════════════════════
   COLLAPSIBLE SIDEBAR + FULL RESPONSIVE DESIGN
   Pattern: GitHub / Azure Portal / AWS Console (2026 standard)
   ═══════════════════════════════════════════════════════════════ */

/* ── Sidebar transitions ─────────────────────────────────────── */
.elite-sidebar {
  transition: width 0.22s cubic-bezier(.4,0,.2,1),
              transform 0.22s cubic-bezier(.4,0,.2,1);
  will-change: width, transform;
}

.elite-main, .elite-footer {
  transition: margin-left 0.22s cubic-bezier(.4,0,.2,1);
}

/* ── Collapsed sidebar (desktop/tablet) ──────────────────────── */
body.sidebar-collapsed .elite-sidebar {
  width: 56px;
  overflow: hidden;
}

body.sidebar-collapsed .elite-main,
body.sidebar-collapsed .elite-footer {
  margin-left: 56px;
}

/* Hide labels, text, badges in collapsed state */
body.sidebar-collapsed .sidebar-section-label { display: none; }
body.sidebar-collapsed .elite-sidebar .nav-link span,
body.sidebar-collapsed .elite-sidebar .nav-link .sidebar-badge { display: none; }
body.sidebar-collapsed .elite-sidebar .nav-link {
  justify-content: center;
  padding: .55rem 0;
}
body.sidebar-collapsed .elite-sidebar .nav-link i {
  width: auto;
  font-size: 1.05rem;
  margin-right: 0 !important;
}

/* Tooltip on collapsed icons */
body.sidebar-collapsed .elite-sidebar .nav-link {
  position: relative;
}
body.sidebar-collapsed .elite-sidebar .nav-link::after {
  content: attr(data-label);
  position: absolute;
  left: 60px;
  top: 50%;
  transform: translateY(-50%);
  background: #1a1a2e;
  color: #fff;
  font-size: .78rem;
  font-weight: 500;
  padding: .3rem .7rem;
  border-radius: 4px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity .15s .08s;
  z-index: 2000;
  box-shadow: 0 2px 8px rgba(0,0,0,.3);
}
body.sidebar-collapsed .elite-sidebar .nav-link:hover::after {
  opacity: 1;
}

/* ── Sidebar toggle button (in navbar) ───────────────────────── */
.sidebar-toggle-btn {
  background: none;
  border: none;
  color: rgba(255,255,255,.75);
  font-size: 1.1rem;
  padding: .35rem .6rem;
  border-radius: 4px;
  cursor: pointer;
  margin-right: .5rem;
  transition: color .15s, background .15s;
  line-height: 1;
}
.sidebar-toggle-btn:hover { color: #fff; background: rgba(255,255,255,.1); }
.sidebar-toggle-btn:focus { outline: none; }

/* ── Overlay (mobile only) ────────────────────────────────────── */
#sidebarOverlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 1019;
  opacity: 0;
  transition: opacity .22s;
}
#sidebarOverlay.visible {
  display: block;
  opacity: 1;
}

/* ═══════════════════════════════════════════════════════════════
   RESPONSIVE BREAKPOINTS
   ═══════════════════════════════════════════════════════════════ */

/* ── Tablet landscape (992–1199px) ───────────────────────────── */
@media (max-width: 1199px) {
  .elite-sidebar { width: 195px; }
  .elite-main, .elite-footer { margin-left: 195px; }
  body.sidebar-collapsed .elite-main,
  body.sidebar-collapsed .elite-footer { margin-left: 56px; }
}

/* ── Tablet portrait (768–991px): collapsed by default ──────── */
@media (max-width: 991px) {
  .elite-sidebar { width: 56px; overflow: hidden; }
  .elite-main, .elite-footer { margin-left: 56px; }

  /* Show text when sidebar is expanded on tablet */
  body.sidebar-expanded .elite-sidebar { width: 215px; }
  body.sidebar-expanded .elite-main,
  body.sidebar-expanded .elite-footer { margin-left: 215px; }

  /* Apply collapsed-icon styles by default on tablet */
  .elite-sidebar .sidebar-section-label { display: none; }
  .elite-sidebar .nav-link span,
  .elite-sidebar .nav-link .sidebar-badge { display: none; }
  .elite-sidebar .nav-link { justify-content: center; padding: .55rem 0; }
  .elite-sidebar .nav-link i { width: auto; font-size: 1.05rem; margin-right: 0 !important; }
  .elite-sidebar .nav-link::after {
    content: attr(data-label);
    position: absolute;
    left: 60px;
    top: 50%;
    transform: translateY(-50%);
    background: #1a1a2e;
    color: #fff;
    font-size: .78rem;
    font-weight: 500;
    padding: .3rem .7rem;
    border-radius: 4px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity .15s .08s;
    z-index: 2000;
    box-shadow: 0 2px 8px rgba(0,0,0,.3);
  }
  .elite-sidebar .nav-link:hover::after { opacity: 1; }

  /* When expanded on tablet, restore text */
  body.sidebar-expanded .elite-sidebar .sidebar-section-label { display: block; }
  body.sidebar-expanded .elite-sidebar .nav-link span { display: inline; }
  body.sidebar-expanded .elite-sidebar .nav-link .sidebar-badge { display: inline; }
  body.sidebar-expanded .elite-sidebar .nav-link { justify-content: flex-start; padding: .45rem 1rem; }
  body.sidebar-expanded .elite-sidebar .nav-link i { width: 18px; font-size: inherit; margin-right: .5rem !important; }
  body.sidebar-expanded .elite-sidebar .nav-link::after { display: none; }
}

/* ── Mobile (< 768px): off-canvas drawer ────────────────────── */
@media (max-width: 767px) {
  .elite-sidebar {
    width: 240px;
    transform: translateX(-100%);
    top: 60px;
    box-shadow: none;
  }
  .elite-main, .elite-footer {
    margin-left: 0;
  }

  /* When open on mobile */
  body.sidebar-mobile-open .elite-sidebar {
    transform: translateX(0);
    box-shadow: 4px 0 20px rgba(0,0,0,.35);
  }

  /* Restore full sidebar styles on mobile drawer */
  .elite-sidebar .sidebar-section-label { display: block; }
  .elite-sidebar .nav-link span { display: inline; }
  .elite-sidebar .nav-link .sidebar-badge { display: inline; }
  .elite-sidebar .nav-link { justify-content: flex-start; padding: .45rem 1rem; }
  .elite-sidebar .nav-link i { width: 18px; font-size: inherit; margin-right: .5rem !important; }
  .elite-sidebar .nav-link::after { display: none !important; }

  /* Full-width content */
  .elite-main { padding: 1rem .75rem; }

  /* Responsive tables */
  .table-responsive-stack td, .table-responsive-stack th {
    display: block;
    width: 100%;
  }
}

/* ── Small mobile (< 480px) ──────────────────────────────────── */
@media (max-width: 479px) {
  .elite-navbar .nav-right .user-badge { display: none; }
  .elite-main { padding: .75rem .5rem; }
  .card-body { padding: .75rem; }
  .kpi-card-body { height: 84px; }
  .kpi-card-value { font-size: 1.5rem; }
}

/* ── Responsive form rows ────────────────────────────────────── */
@media (max-width: 767px) {
  .form-row { flex-direction: column; }
  .form-row > [class*="col-"] { max-width: 100%; flex: 0 0 100%; }
  .btn-block-mobile { display: block; width: 100%; }
  .page-header { flex-wrap: wrap; gap: .5rem; }
}

/* ── Responsive chart height ─────────────────────────────────── */
@media (max-width: 767px) {
  .chart-div { height: 220px; }
}

/* ── Touch-friendly tap targets ──────────────────────────────── */
@media (max-width: 991px) {
  .elite-sidebar .nav-link { min-height: 44px; }
  .btn { min-height: 36px; }
  .btn-xs { min-height: 28px; }
}

/* ── Chart containers ─────────────────────────────────────────── */
.js-plotly-plot .plotly { border-radius: var(--elite-card-radius); }

/* ── Clickable KPI cards ──────────────────────────────────────── */
a.kpi-card-link {
  display: block;
  text-decoration: none;
  color: inherit;
}
a.kpi-card-link:hover {
  text-decoration: none;
  color: inherit;
}
a.kpi-card-link:hover .card.elite-kpi-card {
  box-shadow: 0 4px 14px rgba(0,0,0,0.13);
  transform: translateY(-2px);
  transition: box-shadow 0.18s, transform 0.18s;
}
a.kpi-card-link .card.elite-kpi-card {
  transition: box-shadow 0.18s, transform 0.18s;
}
/* Small arrow hint in bottom-right of card */
a.kpi-card-link .kpi-card-body::after {
  content: "\f054";         /* fa-chevron-right */
  font-family: "Font Awesome 5 Free";
  font-weight: 900;
  position: absolute;
  bottom: 8px;
  right: 10px;
  font-size: 0.6rem;
  opacity: 0.25;
}

/* Hard clip — Plotly must never overflow the card */
.chart-wrap {
  position: relative;
  overflow: hidden;      /* clips anything Plotly renders outside the div */
  width: 100%;
}

/* Standardised chart div height — used on all dashboard chart divs */
.chart-div {
  width: 100%;
  height: 300px;
}

/* Plotly's own SVG should never escape */
.js-plotly-plot svg { max-width: 100% !important; }

/* ═══════════════════════════════════════════════════════════════
   TOAST NOTIFICATION SYSTEM (replaces inline flash alerts)
   Fixed-position — never shifts page layout — 2026 standard
   ═══════════════════════════════════════════════════════════════ */
#eliteToastContainer {
  position: fixed;
  top: 70px;
  right: 16px;
  z-index: 1090;
  width: 360px;
  max-width: calc(100vw - 32px);
  pointer-events: none;
}
.elite-toast {
  pointer-events: all;
  position: relative;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0,0,0,.15), 0 1px 4px rgba(0,0,0,.08);
  border-left: 4px solid #6c757d;
  margin-bottom: 10px;
  padding: .75rem 1rem;
  display: flex;
  align-items: flex-start;
  gap: .65rem;
  font-size: .875rem;
  opacity: 0;
  transform: translateX(20px);
  transition: opacity .25s ease, transform .25s ease;
  overflow: hidden;
}
.elite-toast.show  { opacity: 1; transform: translateX(0); }
.elite-toast.hide  { opacity: 0; transform: translateX(20px); }
.elite-toast.toast-success { border-left-color: #27ae60; }
.elite-toast.toast-danger  { border-left-color: #e74c3c; }
.elite-toast.toast-warning { border-left-color: var(--elite-orange, #f08801); }
.elite-toast.toast-info    { border-left-color: #2980b9; }
.elite-toast .toast-icon  { margin-top: 1px; flex-shrink: 0; }
.elite-toast .toast-msg   { flex: 1; line-height: 1.4; color: #2d2d2d; }
.elite-toast .toast-close {
  background: none; border: none; padding: 0;
  color: #adb5bd; cursor: pointer; font-size: 1rem; line-height: 1;
  flex-shrink: 0;
}
.elite-toast .toast-close:hover { color: #495057; }
.elite-toast .toast-bar {
  position: absolute; bottom: 0; left: 0;
  height: 2px; width: 100%;
  opacity: .3;
  transition: width linear;
}
.toast-success .toast-bar { background: #27ae60; }
.toast-danger  .toast-bar { background: #e74c3c; }
.toast-warning .toast-bar { background: var(--elite-orange, #f08801); }
.toast-info    .toast-bar { background: #2980b9; }
@media (max-width: 479px) {
  #eliteToastContainer { right: 8px; left: 8px; width: auto; }
}

/* ── Scrollbar ───────────────────────────────────────────────── */
.elite-sidebar::-webkit-scrollbar { width: 4px; }
.elite-sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 2px; }
