/* ═══════════════════════════════════════════════════════════════
   main.css — Manaaki CRM Global Design System
   /static/css/main.css
═══════════════════════════════════════════════════════════════ */

/* ── FONTS ── */
@font-face { font-family:'NetflixSans'; src:url('/static/fonts/NetflixSans-Lt.ttf') format('truetype'); font-weight:300; font-display:swap; }
@font-face { font-family:'NetflixSans'; src:url('/static/fonts/NetflixSans-Rg.ttf') format('truetype'); font-weight:400; font-display:swap; }
@font-face { font-family:'NetflixSansItalic'; src:url('/static/fonts/NetflixSans-LtIt.ttf') format('truetype'); font-weight:400; font-style:italic; font-display:swap; }

/* ═══ DESIGN TOKENS ═══ */
:root {
  --primary:    #356267;
  --secondary:  #41737c;
  --accent:     #c2f2f2;
  --bg:         #effefb;
  --surface:    #ffffff;
  --surface-2:  #f8faf9;
  --border:     #d4eded;
  --border-subtle: #e8f5f2;
  --text:       #1a3a3d;
  --text-2:     #41737c;
  --text-3:     #7fa8ad;
  --red:        #dc2626;
  --red-soft:   #fef2f2;
  --green:      #16a34a;
  --green-soft: #f0fdf4;
  --amber:      #d97706;
  --amber-soft: #fffbeb;
  --blue:       #2563eb;

  --font:       'NetflixSans', system-ui, -apple-system, sans-serif;
  --font-italic:'NetflixSansItalic', var(--font);
  --radius:     14px;
  --radius-sm:  9px;
  --radius-xs:  6px;
  --shadow:     0 1px 3px rgba(0,0,0,.05);
  --shadow-md:  0 4px 12px rgba(53,98,103,.08);
  --shadow-lg:  0 10px 40px rgba(53,98,103,.1);
  --transition: .2s ease;

  --sidebar-w:       260px;
  --sidebar-w-mini:  68px;
  --topbar-h:        0px;
}

/* ═══ DARK / WARM THEME ═══ */
[data-theme="dark"] {
  --primary:       #716232;
  --secondary:     #B0926A;
  --accent:        #E1C58F;
  --bg:            #FCE7CA;
  --surface:       #fff8ef;
  --surface-2:     #f5e4cc;
  --border:        #E1C58F;
  --border-subtle: #edd9b8;
  --text:          #3d2e14;
  --text-2:        #716232;
  --text-3:        #B0926A;
  --red:           #b91c1c;
  --red-soft:      #fce8e8;
  --green:         #15803d;
  --green-soft:    #ecfdf5;
  --amber:         #b45309;
  --amber-soft:    #fff7e6;
}

/* ═══ RESET + BASE ═══ */
*, *::before, *::after { box-sizing: border-box; margin: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font);
  font-weight: 300;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
h1,h2,h3,h4,h5,h6 { font-weight: 400; color: var(--text); line-height: 1.2; }
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
input,select,textarea,button { font-family: inherit; }

/* ═══ LAYOUT SHELL ═══ */
.app-shell { display: flex; min-height: 100vh; }

/* ── SIDEBAR ── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: sticky;
  top: 0;
  flex-shrink: 0;
  transition: width .25s ease;
  justify-content: space-between;
  overflow: hidden;
  z-index: 50;
}
.sidebar.collapsed { width: var(--sidebar-w-mini); }
.sidebar.collapsed .sidebar-label,
.sidebar.collapsed .sidebar-section-title,
.sidebar.collapsed .sidebar-user-info,
.sidebar.collapsed .sidebar-logo-text,
.sidebar.collapsed .sidebar-search { display: none; }
.sidebar.collapsed .sidebar-logo { justify-content: center; }
.sidebar.collapsed .nav-item { justify-content: center; padding: 10px; }
.sidebar.collapsed .nav-item .nav-icon { margin: 0; }

/* Sidebar logo */
.sidebar-logo {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px; flex-shrink: 0;
}
.sidebar-logo-text { font-size: 18px; font-weight: 400; letter-spacing: -.3px; }
.sidebar-logo-text em { font-family: var(--font-italic); color: var(--secondary); font-style: italic; }
.sidebar-toggle {
  width: 28px; height: 28px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text-3); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition);
}
.sidebar-toggle:hover { border-color: var(--primary); color: var(--primary); }
.sidebar-toggle svg { width: 14px; height: 14px; stroke: currentColor; stroke-width: 1.5; fill: none; }

/* Sidebar search */
.sidebar-search {
  padding: 0 16px 12px; flex-shrink: 0;
}
.sidebar-search input {
  width: 100%; padding: 8px 12px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface);
  font-size: 13px; color: var(--text); outline: none;
  transition: border-color var(--transition);
}
.sidebar-search input:focus { border-color: var(--primary); }
.sidebar-search input::placeholder { color: var(--text-3); }

/* Sidebar nav */
.sidebar-nav { flex: 1; overflow-y: auto; padding: 0 10px; }
.sidebar-nav::-webkit-scrollbar {
  width: 4px;
}

.sidebar.collapsed .sidebar-nav {
  overflow: hidden; /* 🔥 FIX SCROLL ISSUE */
}

.sidebar-nav::-webkit-scrollbar-thumb {
  background: rgba(53,98,103,0.3);
  border-radius: 4px;
}

.sidebar.collapsed .nav-badge {
  top: 4px;
  right: 4px;
}

/* .sidebar-nav::-webkit-scrollbar { width: 3px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; } */

.sidebar-section { margin-bottom: 26px; }
.sidebar-section-title {
  padding: 0 14px;
  margin-bottom: 10px;
  opacity: 0.7;
}
/* .sidebar-section-title {
  font-size: 10px; font-weight: 400; text-transform: uppercase;
  letter-spacing: .1em; color: var(--text-3); padding: 0 12px; margin-bottom: 6px;
} */

.nav-item {
  
  display: flex;
  align-items: center;
  gap: 12px;

  padding: 10px 14px;
  border-radius: 12px;

  font-size: 13.5px;
  font-weight: 300;
  color: var(--text-2);

  position: relative;
  cursor: pointer;

  transition: 
    background 0.2s ease,
    color 0.2s ease,
    transform 0.15s ease;
}
.nav-item:hover {
  background: rgba(194,242,242,0.35);
  color: var(--primary);
  transform: translateX(4px);
}
/* .nav-item:hover { background: var(--accent); color: var(--primary); transform: translateX(3px); } */

.nav-item.active {
  background: linear-gradient(
    135deg,
    rgba(53,98,103,0.95),
    rgba(65,115,124,0.95)
  );

  color: #fff;

  box-shadow:
    0 6px 20px rgba(53,98,103,0.25),
    0 0 0 1px rgba(255,255,255,0.08) inset;

  transform: translateX(4px);

  font-family: var(--font-italic);
}

/* .nav-item.active {
  background: var(--primary);
  color: white;

  box-shadow:
    0 4px 12px rgba(53,98,103,.2),
    0 0 0 1px rgba(255,255,255,0.1) inset,
    0 0 12px rgba(53,98,103,.4);

  font-family: var(--font-italic);
  font-style: italic;
} */

.nav-item.active .nav-icon {
  stroke: #ffffff;
  filter: drop-shadow(0 0 6px rgba(255,255,255,0.6));
}

.nav-icon {
  width: 18px;
  height: 18px;

  stroke: currentColor;
  stroke-width: 1.7;

  opacity: 0.85;
  transition: all 0.2s ease;
}

.nav-item:hover .nav-icon {
  opacity: 1;
  transform: scale(1.08);
}

.sidebar.collapsed {
  width: 72px;
}

.sidebar.collapsed .nav-item {
  justify-content: center;
  padding: 12px;
}

.nav-item::before {
  content: "";
  position: absolute;
  left: 4px;
  top: 50%;
  transform: translateY(-50%) scaleY(0);
  
  width: 3px;
  height: 60%;
  border-radius: 2px;

  background: var(--primary);

  transition: transform 0.2s ease;
}

.nav-item:hover::before {
  transform: translateY(-50%) scaleY(1);
}

.nav-icon {
  width: 18px; height: 18px; flex-shrink: 0;
  stroke: currentColor; stroke-width: 1.5; fill: none;
}
.nav-badge {
  position: absolute;
  top: 6px;
  right: 10px;

  min-width: 16px;
  height: 16px;
  padding: 0 4px;

  border-radius: 8px;
  background: var(--red);
  color: #fff;

  font-size: 9px;
  font-weight: 400;
  line-height: 16px;
  text-align: center;

  border: 2px solid var(--bg);
}

/* Sidebar tooltip (collapsed) */
.sidebar.collapsed .nav-item { position: relative; }
.sidebar.collapsed .nav-item::after {
  content: attr(data-label);

  position: absolute;
  left: calc(100% + 12px);
  top: 50%;
  transform: translateY(-50%) scale(0.95);

  padding: 8px 14px;
  border-radius: 12px;

  background: rgba(255,255,255,0.65);
  backdrop-filter: blur(12px);

  border: 1px solid rgba(255,255,255,0.4);

  color: var(--text);
  font-size: 12px;

  white-space: nowrap;
  opacity: 0;

  transition: all 0.15s ease;
}

.sidebar.collapsed .nav-item:hover::after {
  opacity: 1;
  transform: translateY(-50%) scale(1);
}

/* .sidebar.collapsed .nav-item:hover::after {
  opacity: 1;
  transform: translateY(-50%) scale(1);
} */
.sidebar.collapsed .nav-item:hover::after { display: block; }

/* Sidebar user panel */
.sidebar-user {
  padding: 14px 14px;
  border-top: 1px solid var(--border);
}

.sidebar-user-row {
  display: flex;
  align-items: center;
  gap: 12px;

  padding: 10px 12px;
  border-radius: 14px;

  background: rgba(255,255,255,0.6);
  backdrop-filter: blur(8px);

  border: 1px solid var(--border-subtle);

  transition: all 0.2s ease;
}

.sidebar-user-row:hover {
  background: var(--accent);
  transform: translateY(-1px);
}

.sidebar-avatar {
  width: 42px;
  height: 42px;

  border-radius: 50%;
  overflow: hidden;

  background: var(--secondary);
  color: #fff;

  display: flex;
  align-items: center;
  justify-content: center;

  font-size: 15px;
  font-weight: 400;

  box-shadow: 0 4px 12px rgba(53,98,103,.25);
}

.sidebar {
  border-right: 1px solid rgba(53,98,103,0.12);
  box-shadow: inset -1px 0 0 rgba(255,255,255,0.4);
}

/* .sidebar-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--secondary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 400; flex-shrink: 0; overflow: hidden;
} */
.sidebar-avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.sidebar-user-info {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start; /* 🔥 KEY FIX */
}

.sidebar-user-name {
  font-size: 13.5px;
  font-weight: 400;
  color: var(--text);
}

.sidebar-user-role {
  font-size: 11px;
  color: var(--text-3);
  margin-top: 2px;
}

.sidebar-signout {
  display: block; text-align: center; margin-top: 8px; padding: 6px;
  border-radius: 8px; font-size: 12px; color: var(--red);
  transition: background var(--transition);
}
.sidebar-signout:hover { background: var(--red-soft); }

.sidebar.collapsed .sidebar-user {
  display: flex;
  justify-content: center;
  align-items: center;
}

.sidebar.collapsed .sidebar-user-row {
  background: transparent;
  border: none;
  padding: 6px;
}

.sidebar.collapsed .sidebar-user-info {
  display: none;
}

/* ── MAIN CONTENT ── */
.main-content {
  flex: 1; min-width: 0; display: flex; flex-direction: column;
}
.main-topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 28px; border-bottom: 1px solid var(--border);
  background: var(--surface); flex-shrink: 0; gap: 16px; position: sticky; top: 0; z-index: 40;
}
.main-topbar-title { font-size: 17px; font-weight: 400; }
.main-topbar-actions { display: flex; align-items: center; gap: 10px; }

.main-body { flex: 1; padding: 24px 28px; overflow-y: auto; }

/* ── GLOBAL SEARCH (topbar) ── */
.global-search {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 14px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface-2);
  min-width: 240px; cursor: pointer; transition: border-color var(--transition);
}
.global-search:hover { border-color: var(--primary); }
.global-search svg { width: 16px; height: 16px; stroke: var(--text-3); stroke-width: 1.5; fill: none; flex-shrink: 0; }
.global-search span { font-size: 13px; color: var(--text-3); flex: 1; }
.global-search kbd {
  font-size: 10px; font-weight: 400; color: var(--text-3);
  padding: 2px 6px; border: 1px solid var(--border); border-radius: 4px;
  background: var(--surface); font-family: var(--font);
}

/* ── NOTIFICATION BELL ── */
.bell-btn {
  width: 36px; height: 36px; border-radius: 50%;
  border: 1px solid var(--border); background: var(--surface);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  position: relative; transition: all var(--transition);
}
.bell-btn:hover { border-color: var(--primary); background: var(--accent); }
.bell-btn svg { width: 18px; height: 18px; stroke: var(--text-2); stroke-width: 1.5; fill: none; }
.bell-badge {
  display: none; position: absolute; top: -3px; right: -3px;
  min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 9px; background: var(--red); color: #fff;
  font-size: 10px; font-weight: 400; line-height: 18px; text-align: center;
  border: 2px solid var(--surface);
}

/* Bell dropdown */
.bell-dropdown {
  display: none; position: absolute; top: 44px; right: 0;
  width: 340px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
  z-index: 500; overflow: hidden;
}
.bell-dropdown-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-bottom: 1px solid var(--border-subtle);
}
.bell-dropdown-header span { font-size: 13px; font-weight: 400; }
.bell-dropdown-header button {
  font-size: 12px; color: var(--primary); font-weight: 400;
  background: none; border: none; cursor: pointer;
}
.bell-dropdown-list { max-height: 320px; overflow-y: auto; }
.bell-dropdown-footer {
  padding: 10px 16px; border-top: 1px solid var(--border-subtle); text-align: center;
}
.bell-dropdown-footer a { font-size: 12px; color: var(--primary); font-weight: 400; }

/* ── THEME TOGGLE ── */
.theme-toggle {
  width: 36px; height: 36px; border-radius: 50%;
  border: 1px solid var(--border); background: var(--surface);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: all var(--transition);
}
.theme-toggle:hover { border-color: var(--primary); background: var(--accent); }
.theme-toggle svg { width: 18px; height: 18px; stroke: var(--text-2); stroke-width: 1.5; fill: none; }

/* ── USER AVATAR (topbar) ── */
.topbar-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--secondary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 400; overflow: hidden; cursor: pointer;
}
.topbar-avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }

/* ═══ TYPOGRAPHY HELPERS ═══ */
.font-heading { font-weight: 400; }
.font-body    { font-weight: 300; }
.font-italic  { font-family: var(--font-italic); font-style: italic; }
.text-primary { color: var(--primary); }
.text-secondary { color: var(--secondary); }
.text-muted   { color: var(--text-3); }

/* ═══ RESPONSIVE ═══ */
@media(max-width:768px) {
  .sidebar { position: fixed; left: calc(-1 * var(--sidebar-w)); z-index: 60; transition: left .25s ease; }
  .sidebar.mobile-open { left: 0; }
  .sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.3); z-index: 55; }
  .sidebar.mobile-open ~ .sidebar-overlay { display: block; }
  .main-body { padding: 16px; }
}

/* ═══ QUILL EDITOR OVERRIDES ═══ */
#editor { height: 350px; }
#previewBox ul { list-style-type: disc; padding-left: 20px; }
#previewBox ol { list-style-type: decimal; padding-left: 20px; }
#previewBox a  { color: var(--blue); text-decoration: underline; }
.ql-editor .mention { padding: 3px 8px; border-radius: 6px; font-size: 13px; font-weight: 400; }
.ql-editor .mention[data-id="first_name"],.ql-editor .mention[data-id="last_name"] { background:#3b82f6;color:#fff; }
.ql-editor .mention[data-id="company"]     { background:#8b5cf6;color:#fff; }
.ql-editor .mention[data-id="designation"] { background:#f59e0b;color:#fff; }
.ql-editor .mention[data-id="email"]       { background:#22c55e;color:#fff; }
.ql-editor .mention[data-id="linkedin"]    { background:#14b8a6;color:#fff; }
[data-theme="dark"] .ql-toolbar    { background:var(--surface-2);border-color:var(--border); }
[data-theme="dark"] .ql-container  { background:var(--surface);border-color:var(--border);color:var(--text); }
[data-theme="dark"] .ql-editor     { color:var(--text); }
[data-theme="dark"] .ql-mention-list-container { background:var(--surface);color:var(--text);border:1px solid var(--border); }
[data-theme="dark"] .ql-snow .ql-stroke { stroke: var(--text-2); }
[data-theme="dark"] .ql-snow .ql-fill   { fill: var(--text-2); }

/* GLOBAL ANIMATIONS */

.fade-in {
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.topbar-avatar,
.topbar-avatar img,
.topbar-avatar svg {
  width: 32px !important;
  height: 32px !important;
  border-radius: 50%;
  overflow: hidden;
}

.sidebar-avatar,
.sidebar-avatar img,
.sidebar-avatar svg {
  width: 32px !important;
  height: 32px !important;
  border-radius: 50%;
  overflow: hidden;
}

.sidebar {
  transition: width 0.25s cubic-bezier(.4,0,.2,1);
}

.sidebar .sidebar-label {
  transition: opacity 0.2s ease;
}

.sidebar.collapsed .sidebar-label {
  opacity: 0;
}