/* ============================================================
   RevIntelix Layout Patch – revintelix-layout.css
   Collapsible sidebar, toggle control, logo fix,
   full-width analytics expansion, persistence-ready.
   ============================================================ */

/* ----------------------------------------------------------
   CSS CUSTOM PROPERTY OVERRIDES
   We rely on --sidebar-w already defined in each page's :root.
   We add a collapsed width and transition speed.
   ---------------------------------------------------------- */
:root {
  --sidebar-collapsed-w: 0px;
  --sidebar-transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ----------------------------------------------------------
   SIDEBAR BASE – add transition
   Works with existing .sidebar class on <aside>
   ---------------------------------------------------------- */
#sidebar,
.sidebar {
  transition: transform var(--sidebar-transition),
              width var(--sidebar-transition);
  will-change: transform;
}

/* ----------------------------------------------------------
   HEADER & MAIN – add transition for smooth expansion
   ---------------------------------------------------------- */
.header {
  transition: left var(--sidebar-transition);
}
#mainContent,
.main {
  transition: margin-left var(--sidebar-transition);
}

/* ----------------------------------------------------------
   COLLAPSED STATE
   body.sidebar-collapsed drives everything
   ---------------------------------------------------------- */
body.sidebar-collapsed #sidebar,
body.sidebar-collapsed .sidebar {
  transform: translateX(-100%);
}

body.sidebar-collapsed .header {
  left: 0 !important;
}

body.sidebar-collapsed #mainContent,
body.sidebar-collapsed .main {
  margin-left: 0 !important;
}

/* ----------------------------------------------------------
   SIDEBAR TOGGLE BUTTON
   Anchored in the header-left area
   ---------------------------------------------------------- */
#sidebarToggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  min-width: 32px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.03);
  color: #8892a4;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-right: 10px;
  flex-shrink: 0;
  padding: 0;
  line-height: 1;
}

#sidebarToggle:hover {
  background: rgba(0, 180, 216, 0.1);
  border-color: rgba(0, 180, 216, 0.25);
  color: #00b4d8;
}

#sidebarToggle svg {
  width: 16px;
  height: 16px;
  transition: transform 0.3s ease;
}

/* Rotate icon when collapsed */
body.sidebar-collapsed #sidebarToggle svg {
  transform: rotate(180deg);
}

/* Ensure header-left is flex to hold toggle + title */
.header-left {
  display: flex;
  align-items: center;
  gap: 0;
}

/* ----------------------------------------------------------
   SIDEBAR BRAND / LOGO FIX
   Consistent rendering across all pages
   ---------------------------------------------------------- */
.sidebar-brand {
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 11px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  cursor: pointer;
  transition: background 0.2s;
  min-height: 56px;
}

.sidebar-brand:hover {
  background: rgba(0, 180, 216, 0.12);
}

/* Logo image container */
.sidebar-logo {
  width: 38px;
  height: 38px;
  min-width: 38px;
  border-radius: 11px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sidebar-logo img {
  width: 38px;
  height: 38px;
  object-fit: contain;
  display: block;
  border-radius: 11px;
}

/* Brand text next to logo */
.brand-text {
  min-width: 0;
  line-height: 1.2;
  overflow: hidden;
}

.brand-text .brand-name {
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-text .brand-sub {
  font-size: 9.5px;
  color: #8892a4;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ----------------------------------------------------------
   RESPONSIVE OVERRIDES
   ---------------------------------------------------------- */

/* Tablets: 769–1024px */
@media (max-width: 1024px) {
  #sidebarToggle {
    width: 30px;
    height: 30px;
    min-width: 30px;
    margin-right: 8px;
  }
}

/* Mobile: ≤768px — sidebar acts as overlay */
@media (max-width: 768px) {
  #sidebar,
  .sidebar {
    transform: translateX(-100%);
    z-index: 200;
  }

  .header {
    left: 0 !important;
  }

  #mainContent,
  .main {
    margin-left: 0 !important;
  }

  /* When sidebar is open on mobile, show overlay backdrop */
  body.sidebar-mobile-open #sidebar,
  body.sidebar-mobile-open .sidebar {
    transform: translateX(0);
  }

  body.sidebar-mobile-open::after {
    content: '';
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 150;
    backdrop-filter: blur(2px);
  }

  /* Toggle shows hamburger/open icon on mobile */
  body.sidebar-mobile-open #sidebarToggle svg {
    transform: rotate(180deg);
  }
}

/* ----------------------------------------------------------
   UTILITY: prevent layout jump on page load
   Applied briefly via JS to disable transitions on init
   ---------------------------------------------------------- */
body.sidebar-no-transition #sidebar,
body.sidebar-no-transition .sidebar,
body.sidebar-no-transition .header,
body.sidebar-no-transition #mainContent,
body.sidebar-no-transition .main {
  transition: none !important;
}

/* ----------------------------------------------------------
   SETTINGS MODAL – shared styles across all pages
   These supplement page-specific overlay styles where needed.
   ---------------------------------------------------------- */

/* Overlay base (safe to redeclare; pages that have it already win via specificity) */
.ri-settings-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  z-index: 200;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}
.ri-settings-overlay.active {
  display: flex;
}

.ri-settings-panel {
  background: var(--bg-card, #112240);
  border: 1px solid var(--border-light, rgba(255,255,255,0.1));
  border-radius: 14px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
  width: 560px;
  max-width: 94vw;
  max-height: 85vh;
  overflow-y: auto;
  padding: 28px 32px;
  animation: riPanelUp 0.3s ease;
}
@keyframes riPanelUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.ri-settings-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
}
.ri-settings-header h3 {
  margin: 0;
  font-size: 17px;
  color: #fff;
  font-weight: 600;
}
.ri-settings-close {
  background: none;
  border: none;
  color: var(--text-muted, #8892a4);
  font-size: 22px;
  cursor: pointer;
  padding: 2px 8px;
  border-radius: 4px;
  transition: all 0.2s;
}
.ri-settings-close:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.05);
}

/* Section title reused from nav-section-title pattern */
.ri-settings-section {
  font-size: 9.5px;
  text-transform: uppercase;
  color: var(--text-dim, #5a6478);
  letter-spacing: 1.2px;
  padding: 0 0 6px;
  margin-top: 18px;
  font-weight: 700;
}
.ri-settings-section:first-of-type {
  margin-top: 8px;
}

/* Setting row */
.ri-setting-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 11px 0;
  border-bottom: 1px solid var(--border, rgba(255,255,255,0.06));
}
.ri-setting-row label {
  font-size: 13px;
  color: var(--text, #e0e6ed);
}
.ri-setting-row span {
  font-size: 12px;
  color: var(--text-muted, #8892a4);
}
.ri-setting-row input[type=number] {
  width: 64px;
  padding: 5px 8px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border, rgba(255,255,255,0.06));
  border-radius: 5px;
  color: var(--text, #e0e6ed);
  text-align: center;
  font-size: 12px;
  outline: none;
  font-family: inherit;
}
.ri-setting-row input[type=number]:focus {
  border-color: var(--accent, #00b4d8);
}

/* Toggle switch */
.ri-toggle {
  width: 40px;
  height: 22px;
  background: var(--primary-light, #1a3d5c);
  border-radius: 11px;
  position: relative;
  cursor: pointer;
  transition: background 0.2s;
  flex-shrink: 0;
}
.ri-toggle.on {
  background: var(--accent, #00b4d8);
}
.ri-toggle::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  background: #fff;
  border-radius: 50%;
  transition: left 0.2s;
}
.ri-toggle.on::after {
  left: 21px;
}

.ri-settings-footer {
  margin-top: 22px;
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}
.ri-settings-footer .btn {
  padding: 8px 16px;
  border: none;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.ri-settings-footer .btn-save {
  background: linear-gradient(135deg, var(--accent, #00b4d8), var(--accent2, #0077b6));
  color: #fff;
}
.ri-settings-footer .btn-save:hover {
  box-shadow: 0 4px 14px rgba(0, 180, 216, 0.3);
}
.ri-settings-footer .btn-close {
  background: transparent;
  border: 1px solid var(--border, rgba(255,255,255,0.06));
  color: var(--text-muted, #8892a4);
}
.ri-settings-footer .btn-close:hover {
  border-color: var(--accent, #00b4d8);
  color: var(--accent, #00b4d8);
}
/* LOGIN PAGE LOGO */
#loginScreen .login-logo {
  display: flex !important;
  justify-content: center !important;
  align-items: center !important;
  margin-bottom: 16px !important;
  padding: 0 !important;
  background: transparent !important;
}

#loginScreen .login-logo-img {
  width: 260px !important;
  max-width: 80% !important;
  height: auto !important;
  max-height: 120px !important;
  object-fit: contain !important;
  display: block !important;
}

/* SIDEBAR LOGO */
.sidebar-logo {
  width: 150px;
  height: 50px;
  min-width: 150px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  overflow: hidden;
  border-radius: 10px;
  flex-shrink: 0;
}

.sidebar-logo img {
  width: 100%;
  height: auto;
  object-fit: contain;
}

/* Optional: if old class is still used somewhere */
.sidebar-brand > img.login-logo-img {
  width: 44px !important;
  height: 44px !important;
  max-width: 44px !important;
  max-height: 44px !important;
  object-fit: contain !important;
  display: block !important;
  flex-shrink: 0 !important;
}
/* FORCE SIDEBAR LOGO SIZE ACROSS ALL INNER PAGES */
aside.sidebar .sidebar-brand,
#sidebar .sidebar-brand {
  padding: 12px 16px !important;
  min-height: 72px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: flex-start !important;
  gap: 0 !important;
}

aside.sidebar .sidebar-logo,
#sidebar .sidebar-logo {
  width: 160px !important;
  height: 48px !important;
  min-width: 160px !important;
  max-width: 160px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: flex-start !important;
  overflow: hidden !important;
  border-radius: 0 !important;
  flex-shrink: 0 !important;
}

aside.sidebar .sidebar-logo img,
#sidebar .sidebar-logo img {
  width: 160px !important;
  height: 48px !important;
  max-width: 160px !important;
  max-height: 48px !important;
  object-fit: contain !important;
  object-position: left center !important;
  display: block !important;
  border-radius: 0 !important;
}