/* =====================================================================
   TechAriv CRM — shared theme (professional dark)
   Loaded last on every page so it sets the shell (font, sidebar, nav,
   headings, controls) consistently. Page files keep their own layout.
   ===================================================================== */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
  color-scheme: dark;
  --sidebar-w: 270px;

  /* Surfaces */
  --bg: #0d0f13;
  --sidebar: #111318;
  --surface: #15181e;
  --raised: #1c2029;
  --raised-2: #232834;
  --border: #232834;
  --border-strong: #2b3140;

  /* Text */
  --text: #e6e8ee;
  --text-2: #b3b9c6;
  --muted: #8b93a4;
  --faint: #6b7383;

  /* Accent */
  --accent: #5b78f6;
  --accent-hover: #6d88ff;
  --accent-text: #9db0ff;
  --accent-soft: rgba(91, 120, 246, 0.14);
  --accent-ring: rgba(91, 120, 246, 0.35);

  /* Status */
  --success: #34d399;
  --warning: #f5a524;
  --danger: #f26d78;

  --radius: 10px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.25);
  --font: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
}

/* ---------- Base ---------- */
html { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
body {
  font-family: var(--font) !important;
  background: var(--bg) !important;
  color: var(--text);
  font-feature-settings: "cv11", "ss01";
}
:where(button, input, select, textarea) { font-family: inherit; }
::selection { background: rgba(91, 120, 246, 0.35); color: #fff; }

/* Scrollbars */
* { scrollbar-width: thin; scrollbar-color: #2b3140 transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #2b3140; border-radius: 10px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: #3a4254; }

/* ---------- Sidebar ---------- */
body .sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar);
  border-right: 1px solid var(--border);
  box-shadow: none;
  padding-bottom: 12px;
  box-sizing: border-box;
}
body .sidebar::-webkit-scrollbar-thumb { background: #232834; border-color: var(--sidebar); }

body .sidebar .logo {
  display: flex;
  align-items: center;
  gap: 2px;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: 0.4px;
  color: #fff;
  margin: 0;
  padding: 26px 24px 22px;
  border-bottom: 1px solid var(--border);
}
body .sidebar .brand-accent { color: var(--accent); font-weight: 800; }

body .sidebar .nav-items {
  margin: 14px 12px 0;
  padding: 0;
  gap: 2px;
  display: flex;
  flex-direction: column;
}
body .sidebar .nav-items a {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-2);
  padding: 9px 12px;
  margin: 0;
  border-radius: 8px;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}
body .sidebar .nav-items a .material-icons {
  font-size: 20px;
  margin-right: 12px;
  color: var(--muted);
  transition: color 0.15s;
}
body .sidebar .nav-items a:hover { background: var(--raised); color: #fff; }
body .sidebar .nav-items a:hover .material-icons { color: var(--text-2); }
body .sidebar .nav-items a.active {
  background: var(--accent-soft);
  color: #fff;
}
body .sidebar .nav-items a.active .material-icons { color: var(--accent-text); }
body .sidebar .nav-items a.active::before {
  content: "";
  position: absolute;
  left: -12px;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--accent);
}
body .sidebar .nav-items a:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

/* Leads group */
body .sidebar .nav-item-header { border-radius: 8px; }
body .sidebar .nav-item-header:hover { background: var(--raised); }
body .sidebar .nav-item-header a:hover { background: transparent; }
body .sidebar .nav-item-header .arrow { margin-left: auto; margin-right: 0; font-size: 18px; }
body .sidebar .nav-item-header.open .arrow { transform: rotate(90deg); }
body .sidebar .leads-submenu { margin: 2px 0 4px; padding-left: 20px; border-left: 1px solid var(--border); margin-left: 22px; }
body .sidebar .leads-submenu a { font-size: 13.5px; padding: 7px 12px; }
body .sidebar .leads-submenu a .material-icons { display: none; }
body .sidebar .leads-submenu a.active::before { left: -21px; }

/* Unread dot in nav */
body .sidebar .red-dot { background: var(--danger); }

/* User footer */
body .sidebar .sidebar-footer {
  margin: 12px 12px 0;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
body .sidebar .sidebar-user-info { margin: 0; gap: 10px; min-width: 0; }
body .sidebar .sidebar-user-circle {
  width: 34px;
  height: 34px;
  font-size: 14px;
  font-weight: 600;
  background: linear-gradient(135deg, #5b78f6, #8b5cf6);
  border: none;
  color: #fff;
  flex: none;
}
body .sidebar .sidebar-user-name {
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: 0;
  line-height: 1.3;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
body .sidebar .sidebar-user-role { font-size: 12px; font-weight: 500; color: var(--muted); }
body .sidebar .sidebar-signout-btn {
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--muted);
  width: 34px;
  height: 34px;
  padding: 0;
  display: grid;
  place-items: center;
  border-radius: 8px;
  flex: none;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
body .sidebar .sidebar-signout-btn .material-icons { font-size: 18px; }
body .sidebar .sidebar-signout-btn:hover { background: rgba(242, 109, 120, 0.12); border-color: rgba(242, 109, 120, 0.4); color: var(--danger); }

/* ---------- Main area ---------- */
body .sidebar ~ .main,
body .sidebar ~ main,
body .main {
  margin-left: var(--sidebar-w);
  background: var(--bg);
}
body .main h1,
body main h1 {
  font-size: 24px;
  font-weight: 650;
  letter-spacing: -0.01em;
  color: #fff;
}

/* ---------- Controls (low specificity: pages can still style their own) ---------- */
:where(input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]):not([type="color"]), select, textarea) {
  color-scheme: dark;
}
:where(input, select, textarea):focus { outline: none; }
:where(input:not([type="checkbox"]):not([type="radio"]), select, textarea):focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}
:where(input, textarea)::placeholder { color: var(--faint); }
:where(button, a, [role="button"]):focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
:where(input[type="checkbox"], input[type="radio"]) { accent-color: var(--accent); }
:where(button) { transition: background-color 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s; }

/* Tables */
:where(table) { border-color: var(--border); }
:where(th) { font-weight: 600; }

/* Material icons render crisper with the new font */
.material-icons { -webkit-font-smoothing: antialiased; }

/* ---------- Auth screens (login / signup / auth) ---------- */
body .login-container,
body .signup-container,
body .box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
}

@media (prefers-reduced-motion: reduce) {
  * { transition-duration: 0.01ms !important; }
}

/* =====================================================================
   Polish layer: unifies page-specific pieces under the new theme
   ===================================================================== */

/* Headings: neutral, not accent-coloured */
body :is(.main, main, .popup, .modal-content, #transPopup, #profitPopup, .login-container, .chat-container) :is(h1, h2, h3) {
  color: #f3f4f7 !important;
  letter-spacing: -0.01em;
}
body main > h2:first-of-type { font-size: 24px; font-weight: 650 !important; }

/* Buttons without their own border no longer get the browser's white bevel */
:where(button) { border: 1px solid transparent; }

/* Sign out — works for icon-only and text buttons */
body .sidebar .sidebar-signout-btn { width: auto; min-width: 34px; padding: 0 10px; font-size: 13px; font-weight: 600; line-height: 1.1; }

/* Alternate sidebar footer used on some pages (.profile-block) */
body .sidebar .profile-block {
  margin: 12px;
  width: auto;
  left: 0;
  right: 0;
  padding: 12px;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-sizing: border-box;
  display: flex;
  align-items: center;
}
body .sidebar .profile-block .profile-pic {
  width: 34px;
  height: 34px;
  min-width: 34px;
  border-radius: 50%;
  margin: 0;
  border: none;
  background: linear-gradient(135deg, #5b78f6, #8b5cf6);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  display: grid;
  place-items: center;
  object-fit: cover;
}
body .sidebar .profile-block :is(.profile-info, .profile-details) { min-width: 0; flex: 1; }
body .sidebar .profile-block :is(.profile-name, .name) { font-size: 13.5px; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
body .sidebar .profile-block :is(.profile-role, .email) { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
body .sidebar .profile-block button {
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--muted);
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  margin: 0;
  flex: none;
}
body .sidebar .profile-block button:hover { background: rgba(242, 109, 120, 0.12); border-color: rgba(242, 109, 120, 0.4); color: var(--danger); }

/* Cards & panels: one surface, hairline border, soft shadow */
body :is(.card, .card-big, .stat-card, .purple-card, .summary-card, .lead-card, .table-container, .table-wrapper, .chat-container) {
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
body :is(.stat-card, .card-big, .purple-card, .summary-card, .card) { border-radius: 12px; }
body .stat-title { text-transform: none; letter-spacing: 0; font-size: 13px; font-weight: 500; color: var(--muted); }
body :is(.card-title, .card-title2) { color: var(--text-2); font-weight: 600; letter-spacing: 0; }

/* Popups & modals */
body :is(.popup, .modal-content, #transPopup, #profitPopup, .bulk-upload-popup-content) {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55);
}
body :is(#popupOverlay, #profitPopupOverlay, .modal, .popup-overlay, .overlay) { backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }

/* Tables: quiet headers, hairline rows, hover */
body .main table th, body main table th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  border-color: var(--border);
}
body .main table td, body main table td { border-color: var(--border); }
body .main table tbody tr, body main table tbody tr { transition: background-color 0.12s; }
body .main table tbody tr:hover, body main table tbody tr:hover { background-color: rgba(255, 255, 255, 0.025); }

/* Inputs on auth screens */
body .login-container input, body .signup-container input {
  box-sizing: border-box;
  border: 1px solid var(--border-strong);
  background: var(--raised);
}
body .login-container input:focus, body .signup-container input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}
body .login-container button, body .signup-container button { box-sizing: border-box; }
body .login-container button:hover, body .signup-container button:hover { background: var(--accent-hover); }
body .sidebar .profile-block #signOutBtn { background: transparent; border: 1px solid var(--border-strong); color: var(--muted); box-shadow: none; }
body .sidebar .profile-block #signOutBtn:hover { background: rgba(242, 109, 120, 0.12); border-color: rgba(242, 109, 120, 0.4); color: var(--danger); }

/* ---------- Brand ---------- */
body .sidebar .logo { gap: 11px; }
body .sidebar .logo .logo-mark { width: 30px; height: 30px; flex: none; display: block; filter: drop-shadow(0 4px 12px rgba(91, 120, 246, 0.35)); }
body .sidebar .logo .logo-word { font-size: 19px; font-weight: 650; letter-spacing: -0.02em; color: #f3f4f7; }
body .sidebar .sidebar-user-info { flex: 1; min-width: 0; }
body .sidebar .sidebar-user-details { min-width: 0; flex: 1; }
body .sidebar .sidebar-user-role { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* =====================================================================
   Unified sidebar (same markup on every page)
   ===================================================================== */
body .sidebar {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  z-index: 100;
  overflow-y: auto;
  overflow-x: hidden;
}
body .sidebar .sidebar-top { display: flex; flex-direction: column; min-height: 0; }
body .sidebar a.logo { text-decoration: none; }
body .sidebar .nav-items { margin-top: 14px; margin-bottom: 14px; }

/* Leads group */
body .sidebar .nav-group { display: flex; flex-direction: column; }
body .sidebar .nav-group-toggle {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
  margin: 0;
  padding: 9px 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text-2);
  font: 500 14px var(--font);
  text-align: left;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
body .sidebar .nav-group-toggle .material-icons { font-size: 20px; margin-right: 12px; color: var(--muted); transition: color 0.15s, transform 0.25s cubic-bezier(.2,.75,.2,1); }
body .sidebar .nav-group-toggle .nav-caret { margin: 0 0 0 auto; font-size: 18px; }
body .sidebar .nav-group-toggle:hover { background: var(--raised); color: #fff; }
body .sidebar .nav-group-toggle:hover .material-icons { color: var(--text-2); }
body .sidebar .nav-group-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
body .sidebar .nav-group.open .nav-caret { transform: rotate(180deg); }
body .sidebar .nav-group.has-active > .nav-group-toggle { color: #fff; }
body .sidebar .nav-group.has-active > .nav-group-toggle .material-icons:first-child { color: var(--accent-text); }
body .sidebar .nav-group.has-active:not(.open) > .nav-group-toggle { background: var(--accent-soft); }
body .sidebar .nav-group.has-active:not(.open) > .nav-group-toggle::before {
  content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent);
}
body .sidebar .nav-sub { display: grid; grid-template-rows: 0fr; transition: grid-template-rows 0.25s cubic-bezier(.2,.75,.2,1); }
body .sidebar .nav-group.open .nav-sub { grid-template-rows: 1fr; }
body .sidebar .nav-sub-inner { overflow: hidden; display: flex; flex-direction: column; gap: 2px; margin-left: 21px; padding-left: 12px; border-left: 1px solid var(--border); }
body .sidebar .nav-group.open .nav-sub-inner { margin-top: 2px; margin-bottom: 4px; }
body .sidebar .nav-sub-inner a { font-size: 13.5px; padding: 7px 12px; }
body .sidebar .nav-sub-inner a.active::before { left: -13px; }

/* Unread dot next to Chat */
body .sidebar .nav-items a .red-dot { width: 8px; height: 8px; border-radius: 50%; margin-left: auto; display: none; }

/* Footer: identical everywhere */
body .sidebar .sidebar-footer { flex: none; }
body .sidebar .sidebar-signout-btn,
body .sidebar #signOutBtn.sidebar-signout-btn {
  width: 34px; min-width: 34px; height: 34px; padding: 0;
  display: grid; place-items: center;
  background: transparent; border: 1px solid var(--border-strong); border-radius: 8px;
  color: var(--muted); box-shadow: none; cursor: pointer;
}
body .sidebar .sidebar-signout-btn:hover,
body .sidebar #signOutBtn.sidebar-signout-btn:hover { background: rgba(242,109,120,.12); border-color: rgba(242,109,120,.4); color: var(--danger); }
/* Footer pieces fully defined here so every page renders it the same, with or without its own CSS */
body .sidebar .sidebar-footer { display: flex; flex-direction: row; align-items: center; justify-content: space-between; gap: 8px; }
body .sidebar .sidebar-user-info { display: flex; flex-direction: row; align-items: center; gap: 10px; }
body .sidebar .sidebar-user-circle { display: grid; place-items: center; border-radius: 50%; box-sizing: border-box; line-height: 1; }
body .sidebar .sidebar-user-details { display: flex; flex-direction: column; gap: 2px; }
body .sidebar .sidebar-user-name, body .sidebar .sidebar-user-role { margin: 0; text-transform: none; }
body .sidebar .sidebar-user-role::first-letter { text-transform: uppercase; }
