/* ═══════════════════════════════════════════════════════════════════════════
   Entarch UI Redesign — ui-redesign.css
   Loads AFTER sidebar.css so these rules win cleanly.
   Do not edit sidebar.css layout rules — only override cosmetics here.
═══════════════════════════════════════════════════════════════════════════ */

/* ── Design Tokens ─────────────────────────────────────────────────────── */
:root {
  --brand-dark:            #0a3d62;
  --brand-mid:             #065a84;
  --accent-blue:           #4fc3f7;
  --body-bg:               #f5f7fa;
  --sidebar-width:         240px;
  --sidebar-gradient:      linear-gradient(180deg, #0a3d62 0%, #065a84 100%);
  --sidebar-text:          rgba(255,255,255,0.82);
  --sidebar-text-muted:    rgba(255,255,255,0.42);
  --sidebar-hover-bg:      rgba(255,255,255,0.12);
  --sidebar-divider-col:   rgba(255,255,255,0.09);
  --sidebar-border-col:    rgba(255,255,255,0.12);
  --transition:            0.3s ease;
}

/* ── Body & Page ───────────────────────────────────────────────────────── */
body {
  background: var(--body-bg);
  font-family: 'Segoe UI', Lato, sans-serif;
}

/* ── Sidebar: cosmetic overrides (layout stays in sidebar.css) ─────────── */
.sidebar {
  background: var(--sidebar-gradient) !important;
  padding-top: 0 !important;
}

/* ── Brand Bar ─────────────────────────────────────────────────────────── */
.sidebar-brand-bar {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 13px 14px 11px;
  border-bottom: 1px solid var(--sidebar-border-col);
  flex-shrink: 0;
}

.sidebar-logo-box {
  width: 30px;
  height: 30px;
  background: var(--accent-blue);
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 12px;
  color: var(--brand-dark);
  flex-shrink: 0;
  letter-spacing: -0.5px;
}

.sidebar-brand-name {
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.4px;
  color: #fff;
}

/* ── User Card ─────────────────────────────────────────────────────────── */
.sidebar-user-card {
  padding: 10px 14px 11px;
  border-bottom: 1px solid var(--sidebar-border-col);
}

.sidebar-user-company {
  font-size: 10px;
  color: rgba(255,255,255,0.52);
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-name {
  font-weight: 600;
  font-size: 13px;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-role {
  font-size: 11px;
  color: var(--accent-blue);
  margin-top: 1px;
}

/* Company switcher inside user card */
.sidebar-company-switcher {
  width: 100%;
  margin-top: 7px;
  padding: 3px 6px;
  font-size: 11px;
  border-radius: 4px;
  border: 1px solid rgba(255,255,255,0.25);
  background: rgba(0,0,0,0.2);
  color: rgba(255,255,255,0.8);
}
.sidebar-company-switcher option { background: #0a3d62; color: #fff; }

/* ── Divider ───────────────────────────────────────────────────────────── */
.sidebar-divider {
  height: 1px;
  background: var(--sidebar-divider-col);
  margin: 5px 12px;
}

/* ── Section Header ────────────────────────────────────────────────────── */
.sidebar-section-hdr {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 1.3px;
  text-transform: uppercase;
  color: var(--sidebar-text-muted);
  padding: 11px 14px 3px;
}

/* ── Nav Items (top-level collapsible headers) ─────────────────────────── */
.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  color: var(--sidebar-text);
  font-size: 12px;
  font-weight: 600;
  text-decoration: none !important;
  border-radius: 6px;
  margin: 1px 6px;
  border-left: 3px solid transparent;
  transition: background var(--transition), border-color 0.15s;
  white-space: nowrap;
}

.sidebar-nav-item:hover {
  background: var(--sidebar-hover-bg);
  color: #fff !important;
  border-left-color: var(--accent-blue);
  text-decoration: none !important;
}

.sidebar-nav-item.active {
  background: var(--sidebar-hover-bg);
  color: #fff !important;
  border-left-color: var(--accent-blue);
}

.sidebar-nav-ico {
  width: 16px;
  text-align: center;
  flex-shrink: 0;
  opacity: 0.88;
  font-size: 13px;
}

/* ── Sub Items (inside collapse divs) ─────────────────────────────────── */
.sidebar-sub-item {
  display: flex !important;
  align-items: center;
  gap: 7px;
  padding: 4px 14px 4px 36px !important;
  color: rgba(255,255,255,0.68) !important;
  font-size: 11px !important;
  font-weight: 400 !important;
  text-decoration: none !important;
  border-left: 3px solid transparent;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
  border-radius: 0;
  margin: 0 !important;
}

.sidebar-sub-item:hover {
  background: var(--sidebar-hover-bg);
  color: #fff !important;
  text-decoration: none !important;
}

/* Nested sub-sub items (e.g. Process inside Business) */
.sidebar-sub-sub-item {
  display: flex !important;
  align-items: center;
  gap: 7px;
  padding: 3px 14px 3px 52px !important;
  color: rgba(255,255,255,0.55) !important;
  font-size: 11px !important;
  text-decoration: none !important;
  transition: background 0.15s;
}
.sidebar-sub-sub-item:hover {
  background: var(--sidebar-hover-bg);
  color: #fff !important;
  text-decoration: none !important;
}

/* Collapse background override */
.sidebar .collapse,
.sidebar .collapsing {
  background: rgba(0,0,0,0.12);
  border-radius: 0 0 6px 6px;
  margin: 0 6px;
}

/* ── Home Link ─────────────────────────────────────────────────────────── */
.sidebar-home-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  color: #fff !important;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none !important;
  transition: background 0.15s;
  margin: 4px 0 2px;
}
.sidebar-home-link:hover {
  background: var(--sidebar-hover-bg);
  text-decoration: none !important;
}

/* ── Alerts Bell Badge (inside sidebar-home-link) ──────────────────────── */
.sidebar-bell-badge {
  margin-left: auto;
  background: #dc3545;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  border-radius: 10px;
  padding: 1px 6px;
  min-width: 20px;
  text-align: center;
  line-height: 1.4;
  cursor: pointer;
}
.sidebar-bell-badge:hover { background: #c0392b; }

/* ── Logout link ───────────────────────────────────────────────────────── */
.sidebar-logout-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  color: rgba(255,255,255,0.65) !important;
  font-size: 12px;
  text-decoration: none !important;
  margin: 4px 6px 10px;
  border-radius: 6px;
  transition: background 0.15s;
}
.sidebar-logout-link:hover {
  background: var(--sidebar-hover-bg);
  color: #fff !important;
  text-decoration: none !important;
}

/* ── Company context / change link ────────────────────────────────────── */
.sidebar-context-row {
  padding: 4px 14px 2px;
  font-size: 11px;
}
.sidebar-context-row a { color: rgba(255,255,255,0.5) !important; font-size: 10px; }
.sidebar-context-row a:hover { color: var(--accent-blue) !important; }

/* ── Suppress old inline-style overrides from base template ────────────── */
/* These selectors match the legacy nav-link/bg-info/nav-item elements that
   remain inside Bootstrap collapse divs — they are now hidden by the new
   sidebar-nav-item / sidebar-sub-item classes above, but we keep them from
   causing visual glitches on the transition. */
.sidebar .nav-link.bg-info {
  background: transparent !important;
  color: var(--sidebar-text) !important;
  padding: 7px 14px !important;
  font-size: 12px !important;
  font-weight: 600 !important;
  border-radius: 6px;
  margin: 1px 6px;
  display: flex;
  align-items: center;
}

/* ── Main content area tweaks ──────────────────────────────────────────── */
#main {
  background: var(--body-bg);
}

/* ── KPI Cards ─────────────────────────────────────────────────────────── */
.kpi-row {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.kpi-card {
  flex: 1;
  min-width: 120px;
  background: #fff;
  border-radius: 10px;
  padding: 13px 16px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.07);
  border-left: 3px solid var(--brand-mid);
}
.kpi-card .kv { font-size: 24px; font-weight: 700; color: var(--brand-mid); line-height: 1.1; }
.kpi-card .kl { font-size: 10px; color: #999; text-transform: uppercase; letter-spacing: 0.5px; margin-top: 3px; }
.kpi-card.green { border-color: #1e8b4c; } .kpi-card.green .kv { color: #1e8b4c; }
.kpi-card.amber { border-color: #f0a030; } .kpi-card.amber .kv { color: #f0a030; }
.kpi-card.red   { border-color: #e74c3c; } .kpi-card.red   .kv { color: #e74c3c; }

/* ── EA Table ──────────────────────────────────────────────────────────── */
.ea-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  background: #fff;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 6px rgba(0,0,0,0.06);
}
.ea-table th {
  background: var(--brand-dark);
  color: #fff;
  padding: 8px 10px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
}
.ea-table td { padding: 7px 10px; border-bottom: 1px solid #f0f0f0; }
.ea-table tr:last-child td { border-bottom: none; }
.ea-table tr:hover td { background: #f7f9fc; }

/* ── Badges ────────────────────────────────────────────────────────────── */
.badge-ea {
  border-radius: 10px;
  padding: 2px 8px;
  font-size: 10px;
  font-weight: 600;
  color: #fff;
  display: inline-block;
}
.badge-ea.blue   { background: var(--brand-mid); }
.badge-ea.green  { background: #1e8b4c; }
.badge-ea.amber  { background: #f0a030; color: #333; }
.badge-ea.red    { background: #e74c3c; }
.badge-ea.grey   { background: #8e9aaf; }

/* ════════════════════════════════════════════════════════════════════════
   TABLET — icon rail (768px–991px)
════════════════════════════════════════════════════════════════════════ */
@media (min-width: 768px) and (max-width: 991.98px) {
  :root { --sidebar-width: 58px; }

  .sidebar {
    margin-left: 0 !important;   /* override sidebar.css mobile hiding */
    width: 58px !important;
    overflow: visible !important;
  }

  /* Hide text, keep icon */
  .sidebar-brand-name,
  .sidebar-user-card,
  .sidebar-section-hdr,
  .sidebar-context-row,
  .sidebar-company-switcher,
  .sidebar-logout-link span,
  .sidebar-home-link span,
  .sidebar-bell-badge { display: none !important; }

  .sidebar-brand-bar { justify-content: center; padding: 10px 0; }
  .sidebar-logo-box  { width: 34px; height: 34px; font-size: 13px; }

  .sidebar-nav-item {
    justify-content: center;
    padding: 9px 0 !important;
    margin: 2px 4px;
    border-left: none;
    border-radius: 8px;
  }
  .sidebar-nav-item .sidebar-nav-ico { font-size: 16px; width: auto; }

  .sidebar-home-link {
    justify-content: center;
    padding: 9px 0 !important;
    margin: 4px 4px 2px;
  }

  .sidebar-logout-link {
    justify-content: center;
    padding: 8px 0 !important;
    margin: 4px 4px 10px;
  }

  /* Collapse sub-menus hidden on icon rail — flyout is a future enhancement */
  .sidebar .collapse,
  .sidebar .collapsing { display: none !important; }

  #main  { margin-left: 58px !important; }
  #sidebarCollapseTab,
  #sidebarRestoreTab  { display: none !important; }

  .mob-bottom-nav { display: none !important; }
}

/* ════════════════════════════════════════════════════════════════════════
   MOBILE — bottom nav + drawer (<768px)
════════════════════════════════════════════════════════════════════════ */
@media (max-width: 767.98px) {
  .sidebar          { display: none !important; }
  #sidebarCollapseTab,
  #sidebarRestoreTab { display: none !important; }
  #main              { margin-left: 0 !important; padding-bottom: 72px; }

  /* ── Bottom Tab Bar ─────────────────────────────────── */
  .mob-bottom-nav {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: 56px;
    background: #fff;
    border-top: 1px solid #e0e4ea;
    display: flex;
    z-index: 1050;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.07);
  }

  .mob-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    font-size: 9px;
    color: #999;
    text-decoration: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    font-family: inherit;
  }
  .mob-nav-item.active { color: var(--brand-mid); }
  .mob-nav-item .mob-nav-icon { font-size: 18px; line-height: 1; }

  /* ── Mobile Drawer Overlay ──────────────────────────── */
  .mob-drawer-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 1060;
    display: none;
  }
  .mob-drawer-overlay.open { display: flex; }

  .mob-drawer {
    width: 270px;
    height: 100%;
    background: var(--sidebar-gradient);
    color: #fff;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    transform: translateX(-270px);
    transition: transform 0.28s ease;
    flex-shrink: 0;
  }
  .mob-drawer-overlay.open .mob-drawer { transform: translateX(0); }

  .mob-drawer-header {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 13px 14px;
    border-bottom: 1px solid var(--sidebar-border-col);
    flex-shrink: 0;
  }
  .mob-drawer-close {
    margin-left: auto;
    font-size: 20px;
    color: rgba(255,255,255,0.6);
    background: none;
    border: none;
    cursor: pointer;
    line-height: 1;
    padding: 0;
  }
  .mob-drawer-close:hover { color: #fff; }

  .mob-drawer-user {
    padding: 10px 14px 11px;
    border-bottom: 1px solid var(--sidebar-border-col);
  }
  .mob-drawer-user .mdu-co  { font-size: 10px; color: rgba(255,255,255,0.5); }
  .mob-drawer-user .mdu-un  { font-size: 13px; font-weight: 600; color: #fff; }
  .mob-drawer-user .mdu-ro  { font-size: 11px; color: var(--accent-blue); }
}

/* Hide bottom nav on desktop/tablet */
@media (min-width: 768px) {
  .mob-bottom-nav    { display: none !important; }
  .mob-drawer-overlay { display: none !important; }
}
