/* ════════════════════════════════════════════════════════════════
   global.css — ProjectCRM System-Wide Stylesheet
   Change color scheme, typography, or layout here and it
   applies to every page that links this file.
════════════════════════════════════════════════════════════════ */

/* ─── Google Fonts ───────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ─── Design Tokens ──────────────────────────────────────────── */
:root {
  /* Brand palette */
  --crimson:       #530606;
  --crimson-light: #7a0a0a;
  --crimson-dark:  #3a0404;
  --crimson-glow:  rgba(83,6,6,.18);
  --crimson-pale:  rgba(83,6,6,.07);

  /* Neutrals */
  --white:         #ffffff;
  --off-white:     #fdf8f8;
  --gray-50:       #f9f5f5;
  --gray-100:      #f0e8e8;
  --gray-200:      #ddd0d0;
  --gray-300:      #c4aaaa;
  --gray-400:      #a07878;
  --gray-500:      #7a5a5a;
  --gray-600:      #5c3f3f;

  /* Text */
  --text-dark:     #1a0a0a;
  --text-mid:      #4a2a2a;
  --text-soft:     #7a5050;

  /* Shadows */
  --shadow-sm:  0 1px 3px rgba(83,6,6,.1),  0 1px 2px rgba(83,6,6,.06);
  --shadow-md:  0 4px 16px rgba(83,6,6,.12), 0 2px 6px rgba(83,6,6,.08);
  --shadow-lg:  0 10px 40px rgba(83,6,6,.2), 0 4px 12px rgba(83,6,6,.1);
  --shadow-xl:  0 20px 60px rgba(83,6,6,.25),0 8px 20px rgba(83,6,6,.12);

  /* Radii */
  --radius-sm:  6px;
  --radius-md:  10px;
  --radius-lg:  16px;
  --radius-xl:  24px;

  /* Motion */
  --transition: all .22s cubic-bezier(.4,0,.2,1);

  /* Sidebar width (change here to affect all pages) */
  --sidebar-width: 260px;
  --sidebar-collapsed-width: 64px;
}

/* ─── Reset & Base ───────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: 'Inter', sans-serif;
  background: var(--off-white);
  color: var(--text-dark);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ─── Background Pattern ─────────────────────────────────────── */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 60% at 10%  5%, rgba(83,6,6,.06) 0%, transparent 60%),
    radial-gradient(ellipse 60% 80% at 90% 90%, rgba(83,6,6,.04) 0%, transparent 60%);
  pointer-events: none;
  z-index: 0;
}

/* ─── Sidebar ────────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  left: 0; top: 0; bottom: 0;
  width: var(--sidebar-width);
  background: linear-gradient(160deg, var(--crimson-dark) 0%, var(--crimson) 60%, var(--crimson-light) 100%);
  display: flex;
  flex-direction: column;
  z-index: 100;
  box-shadow: 4px 0 30px rgba(83,6,6,.35);
}
.sidebar-brand {
  padding: 28px 24px 20px;
  border-bottom: 1px solid rgba(255,255,255,.12);
}
.sidebar-brand .logo-mark {
  width: 42px; height: 42px;
  border-radius: var(--radius-md);
  background: rgba(255,255,255,.15);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; margin-bottom: 12px;
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,.2);
}
.sidebar-brand h1 {
  font-size: 17px; font-weight: 700;
  color: var(--white); letter-spacing: -.3px;
}
.sidebar-brand p {
  font-size: 11px; color: rgba(255,255,255,.55);
  margin-top: 2px; font-weight: 400;
}
.sidebar-nav {
  padding: 16px 12px;
  flex: 1;
  overflow-y: auto;
}
.nav-label {
  font-size: 10px; font-weight: 600;
  color: rgba(255,255,255,.4);
  text-transform: uppercase; letter-spacing: 1px;
  padding: 0 12px; margin-bottom: 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  color: rgba(255,255,255,.7);
  font-size: 13.5px; font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  margin-bottom: 2px;
  text-decoration: none;
}
.nav-item:hover  { background: rgba(255,255,255,.10); color: var(--white); }
.nav-item.active { background: rgba(255,255,255,.18); color: var(--white); }
.nav-item .icon  { font-size: 16px; flex-shrink: 0; }

/* ─── Dropdown nav group ─────────────────────────────────────── */
.nav-dropdown { position: relative; }

/* Toggle row — same look as .nav-item */
.nav-dropdown-toggle {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  color: rgba(255,255,255,.7);
  font-size: 13.5px; font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  margin-bottom: 2px;
  user-select: none;
}
.nav-dropdown-toggle:hover { background: rgba(255,255,255,.10); color: var(--white); }
.nav-dropdown-toggle.open  { background: rgba(255,255,255,.08); color: var(--white); }
.nav-dropdown-toggle .icon { font-size: 16px; flex-shrink: 0; }

/* Chevron arrow */
.nav-dropdown-arrow {
  margin-left: auto;
  font-size: 10px;
  opacity: .55;
  transition: transform .22s cubic-bezier(.4,0,.2,1), opacity .2s;
  display: inline-block;
}
.nav-dropdown-toggle.open .nav-dropdown-arrow {
  transform: rotate(180deg);
  opacity: .85;
}

/* Collapsible sub-item list */
.nav-dropdown-items {
  overflow: hidden;
  max-height: 0;
  transition: max-height .28s cubic-bezier(.4,0,.2,1);
  border-left: 2px solid rgba(255,255,255,.12);
  margin: 0 12px 4px 22px;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
}
.nav-dropdown-items.open { max-height: 400px; }

/* Individual sub-items */
.nav-dropdown-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: rgba(255,255,255,.6);
  font-size: 12.5px; font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  margin-bottom: 1px;
}
.nav-dropdown-item:hover  { background: rgba(255,255,255,.08); color: var(--white); }
.nav-dropdown-item.active { background: rgba(255,255,255,.15); color: var(--white); }
.nav-dropdown-item .sub-icon { font-size: 13px; flex-shrink: 0; opacity: .75; }
.sidebar-footer {
  padding: 16px;
  border-top: 1px solid rgba(255,255,255,.1);
}
.user-chip {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  background: rgba(255,255,255,.1);
  border-radius: var(--radius-md);
}
.user-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: rgba(255,255,255,.25);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: var(--white);
  flex-shrink: 0;
}
.user-info { flex: 1; min-width: 0; }
.user-name { font-size: 12.5px; font-weight: 600; color: var(--white); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 10.5px; color: rgba(255,255,255,.5); }

/* ─── Main Layout ────────────────────────────────────────────── */
.main {
  margin-left: var(--sidebar-width);
  position: relative; z-index: 1;
  min-height: 100vh;
  display: flex; flex-direction: column;
}

/* ─── Topbar ─────────────────────────────────────────────────── */
.topbar {
  background: rgba(255,255,255,.85);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--gray-100);
  padding: 14px 32px;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 50;
}
.topbar-left  { display: flex; align-items: center; gap: 12px; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.breadcrumb {
  display: flex; align-items: center; gap: 6px;
  font-size: 13px; color: var(--text-soft);
}
.breadcrumb span      { color: var(--text-dark); font-weight: 600; }
.breadcrumb .bc-sep   { color: var(--gray-300); font-weight: 400; }
.breadcrumb .bc-root  { color: var(--text-soft); font-weight: 400; }

/* ─── Buttons ────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 18px;
  border-radius: var(--radius-md);
  font-family: 'Inter', sans-serif;
  font-size: 13px; font-weight: 600;
  border: none; cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
}
.btn-primary {
  background: linear-gradient(135deg, var(--crimson) 0%, var(--crimson-light) 100%);
  color: var(--white);
  box-shadow: 0 3px 12px rgba(83,6,6,.35);
}
.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(83,6,6,.45);
}
.btn-ghost {
  background: transparent;
  color: var(--text-mid);
  border: 1.5px solid var(--gray-200);
}
.btn-ghost:hover { background: var(--gray-50); border-color: var(--gray-300); }
.btn-sm   { padding: 6px 12px; font-size: 12px; }
.btn-icon { padding: 8px; border-radius: var(--radius-sm); width: 36px; height: 36px; justify-content: center; }

/* ─── Page Content Wrapper ───────────────────────────────────── */
.content {
  padding: 28px 32px;
  flex: 1;
}

/* ─── Panel (reusable card component) ───────────────────────── */
.panel {
  background: var(--white);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--gray-100);
  overflow: hidden;
}
.panel-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--gray-100);
  display: flex; align-items: center; justify-content: space-between;
  background: linear-gradient(to right, var(--gray-50), var(--white));
}
.panel-title    { font-size: 16px; font-weight: 700; color: var(--text-dark); }
.panel-subtitle { font-size: 12px; color: var(--text-soft); margin-top: 2px; }
.panel-body     { padding: 0; }

/* ─── Forms ──────────────────────────────────────────────────── */
.form-group { margin-bottom: 18px; }
.form-label {
  display: block;
  font-size: 12px; font-weight: 600;
  color: var(--text-mid);
  margin-bottom: 6px;
  letter-spacing: .2px;
}
.form-control {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-md);
  font-family: 'Inter', sans-serif;
  font-size: 13.5px;
  color: var(--text-dark);
  background: var(--white);
  transition: var(--transition);
  outline: none;
}
.form-control:focus {
  border-color: var(--crimson);
  box-shadow: 0 0 0 3px var(--crimson-glow);
}
.form-row              { display: flex; gap: 14px; }
.form-row .form-group  { flex: 1; }
select.form-control    { cursor: pointer; }
textarea.form-control  { resize: vertical; min-height: 80px; }

/* ─── Modal ──────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(26,10,10,.55);
  backdrop-filter: blur(6px);
  z-index: 200;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none;
  transition: opacity .25s ease;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
  background: var(--white);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  width: 520px; max-width: 95vw;
  transform: translateY(20px) scale(.97);
  transition: transform .25s cubic-bezier(.34,1.56,.64,1);
  overflow: hidden;
}
.modal-overlay.open .modal { transform: none; }
.modal-header {
  padding: 22px 26px 18px;
  border-bottom: 1px solid var(--gray-100);
  display: flex; align-items: center; justify-content: space-between;
  background: linear-gradient(to right, var(--crimson-pale), var(--white));
}
.modal-title { font-size: 17px; font-weight: 700; color: var(--text-dark); }
.modal-close {
  width: 32px; height: 32px; border-radius: 50%;
  border: none; background: var(--gray-100);
  cursor: pointer; font-size: 16px; color: var(--text-soft);
  display: flex; align-items: center; justify-content: center;
  transition: var(--transition);
}
.modal-close:hover { background: rgba(83,6,6,.12); color: var(--crimson); }
.modal-body   { padding: 24px 26px; }
.modal-footer {
  padding: 16px 26px;
  border-top: 1px solid var(--gray-100);
  display: flex; justify-content: flex-end; gap: 10px;
  background: var(--gray-50);
}

/* ─── Toast Notifications ────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 28px; right: 28px;
  z-index: 9999;
  display: flex; flex-direction: column; gap: 10px;
}
.toast {
  background: var(--text-dark);
  color: var(--white);
  padding: 14px 20px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-size: 13px; font-weight: 500;
  display: flex; align-items: flex-start; gap: 10px;
  min-width: 280px; max-width: 380px;
  animation: toastIn .3s cubic-bezier(.34,1.56,.64,1) forwards;
  border-left: 4px solid var(--crimson);
}
.toast.fade-out { animation: toastOut .3s ease forwards; }
.toast-icon { font-size: 16px; flex-shrink: 0; margin-top: 1px; }
.toast-msg b { display: block; margin-bottom: 2px; }
@keyframes toastIn  { from { opacity:0; transform:translateX(30px) scale(.95); } to { opacity:1; transform:none; } }
@keyframes toastOut { from { opacity:1; transform:none; } to { opacity:0; transform:translateX(30px) scale(.95); } }

/* ─── Progress Bar ───────────────────────────────────────────── */
.progress-bar-wrap {
  height: 6px;
  background: var(--gray-100);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 4px;
}
.progress-bar-fill {
  height: 100%;
  background: linear-gradient(to right, var(--crimson), var(--crimson-light));
  border-radius: 3px;
  transition: width .6s cubic-bezier(.4,0,.2,1);
}

/* ─── Utility Classes ────────────────────────────────────────── */
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--crimson-pale); color: var(--crimson);
  border-radius: 99px;
  font-size: 11px; font-weight: 600;
  padding: 3px 9px;
}
.divider { height: 1px; background: var(--gray-100); margin: 4px 0; }

/* ─── Responsive ─────────────────────────────────────────────── */
@media (max-width: 900px) {
  .sidebar { width: var(--sidebar-collapsed-width); }
  .sidebar-brand h1, .sidebar-brand p,
  .nav-label, .nav-item span,
  .user-info { display: none; }
  .sidebar-brand .logo-mark { margin: 0 auto; }
  .nav-item  { justify-content: center; padding: 10px; }
  .nav-item .icon { font-size: 20px; }
  .user-chip { justify-content: center; padding: 8px; }
  .main      { margin-left: var(--sidebar-collapsed-width); }
}
@media (max-width: 600px) {
  .content { padding: 16px; }
  .topbar  { padding: 12px 16px; }
}
