/* CRM Admin app styles — references shared tokens */
@import url("colors_and_type.css");

* { box-sizing: border-box; }
html, body, #root { height: 100%; margin: 0; }
body {
  background: var(--bg-page);
  color: var(--fg-1);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--lh-normal);
  -webkit-font-smoothing: antialiased;
}

/* ============ LAYOUT ============ */
.app { display: flex; min-height: 100vh; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.page { padding: 28px 32px 60px; max-width: var(--content-max); width: 100%; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.page-title { font-size: var(--text-3xl); font-weight: 600; letter-spacing: -0.02em; line-height: 1.2; margin: 0; }
.page-sub { color: var(--fg-3); margin-top: 4px; font-size: var(--text-base); }
.eyebrow { font-size: 11px; text-transform: uppercase; letter-spacing: var(--track-caps); font-weight: 600; color: var(--brand-burgundy); }

/* ============ SIDEBAR ============ */
.sidebar {
  width: var(--sidebar-w);
  background: var(--plum-900);
  color: var(--fg-on-sidebar);
  display: flex; flex-direction: column;
  flex-shrink: 0;
  position: sticky; top: 0; height: 100vh;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 18px 14px;
  border-bottom: 1px solid var(--plum-800);
}
.sidebar-brand .wordmark {
  color: #fff; font-weight: 700; letter-spacing: 0.18em; font-size: 15px;
}
.sidebar-brand .sub {
  font-size: 9px; letter-spacing: 0.22em; color: var(--brand-pink); margin-top: 1px;
}
.sidebar-section { padding: 14px 12px 6px; }
.sidebar-section .heading {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.18em;
  color: rgba(244, 221, 232, 0.5); padding: 0 10px 8px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 6px;
  color: var(--fg-on-sidebar);
  text-decoration: none; cursor: pointer;
  font-size: 13.5px;
  transition: background var(--dur-base) var(--ease-standard);
  position: relative;
}
.nav-item:hover { background: var(--bg-sidebar-hov); }
.nav-item.active { background: var(--plum-700); color: #fff; }
.nav-item.active::before {
  content: ""; position: absolute; left: -12px; top: 6px; bottom: 6px;
  width: 3px; border-radius: 0 3px 3px 0; background: var(--brand-pink);
}
.nav-item .icon { width: 18px; height: 18px; flex-shrink: 0; opacity: .85; }
.nav-item .count {
  margin-left: auto; background: var(--brand-magenta); color: #fff;
  font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 999px;
  min-width: 18px; text-align: center;
}

.sidebar-user {
  margin-top: auto; padding: 14px;
  border-top: 1px solid var(--plum-800);
  display: flex; align-items: center; gap: 10px;
}
.sidebar-user .av {
  width: 32px; height: 32px; border-radius: 999px;
  background: var(--brand-pink); color: var(--plum-900);
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 12px;
}
.sidebar-user .name { color: #fff; font-size: 13px; font-weight: 500; }
.sidebar-user .role { color: rgba(244, 221, 232, 0.55); font-size: 11px; }

/* ============ TOPBAR ============ */
.topbar {
  height: var(--topbar-h);
  display: flex; align-items: center;
  padding: 0 32px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  position: sticky; top: 0; z-index: 5;
  gap: 16px;
}
.search {
  flex: 1; max-width: 440px;
  display: flex; align-items: center; gap: 8px;
  background: var(--ink-50); border: 1px solid var(--border-subtle);
  border-radius: 6px; padding: 7px 12px;
}
.search input { flex: 1; border: 0; background: transparent; outline: none; font-family: inherit; font-size: 13.5px; color: var(--fg-1); }
.search input::placeholder { color: var(--fg-4); }

.topbar-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.icon-btn {
  width: 36px; height: 36px; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  background: transparent; border: 0; cursor: pointer;
  color: var(--fg-2); position: relative;
  transition: all var(--dur-base) var(--ease-standard);
}
.icon-btn:hover { background: var(--ink-100); color: var(--fg-1); }
.icon-btn .badge-dot {
  position: absolute; top: 8px; right: 8px;
  width: 8px; height: 8px; background: var(--brand-magenta);
  border-radius: 999px; border: 2px solid #fff;
}

/* ============ BUTTONS ============ */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--font-sans); font-size: 13.5px; font-weight: 500;
  border-radius: 6px; padding: 8px 14px;
  cursor: pointer; border: 1px solid transparent;
  transition: all var(--dur-base) var(--ease-standard);
  white-space: nowrap;
}
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--brand-burgundy); color: #fff; }
.btn-primary:hover { background: var(--plum-700); box-shadow: var(--shadow-brand); }
.btn-secondary { background: #fff; color: var(--fg-1); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--ink-50); border-color: var(--ink-500); }
.btn-ghost { background: transparent; color: var(--brand-burgundy); }
.btn-ghost:hover { background: var(--plum-50); }
.btn-sm { padding: 5px 10px; font-size: 12.5px; }

/* ============ CHIPS ============ */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 500; line-height: 1.4;
  background: var(--ink-100); color: var(--fg-2);
}
.chip .dot { width: 6px; height: 6px; border-radius: 999px; background: var(--fg-3); }
.chip-success { background: var(--success-50); color: var(--success-700); }
.chip-success .dot { background: var(--success-500); }
.chip-warning { background: var(--warning-50); color: var(--warning-700); }
.chip-warning .dot { background: var(--warning-500); }
.chip-danger  { background: var(--danger-50);  color: var(--danger-700); }
.chip-danger  .dot { background: var(--danger-500); }
.chip-info    { background: var(--info-50);    color: var(--info-700); }
.chip-info    .dot { background: var(--info-500); }
.chip-brand   { background: var(--plum-50);    color: var(--brand-burgundy); border: 1px solid var(--plum-200); }

/* ============ CARDS ============ */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}
.card-pad { padding: 18px 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 20px; border-bottom: 1px solid var(--border-subtle); }
.card-title { font-size: 14px; font-weight: 600; margin: 0; }

/* ============ KPI CARDS ============ */
.kpi { display: flex; flex-direction: column; gap: 6px; padding: 16px 18px; background: #fff; border: 1px solid var(--border-subtle); border-radius: var(--radius-md); box-shadow: var(--shadow-sm); }
.kpi .lbl { font-size: 11px; text-transform: uppercase; letter-spacing: 0.12em; color: var(--brand-burgundy); font-weight: 600; }
.kpi .val { font-size: 28px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.1; }
.kpi .delta { font-size: 12px; color: var(--success-700); }
.kpi .delta.down { color: var(--danger-700); }

/* ============ TABLES ============ */
.tbl { width: 100%; border-collapse: separate; border-spacing: 0; }
.tbl thead th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 0.12em;
  color: var(--fg-3); font-weight: 600;
  padding: 10px 16px; background: var(--ink-50);
  border-bottom: 1px solid var(--border-subtle);
}
.tbl tbody td { padding: 12px 16px; font-size: 13.5px; border-bottom: 1px solid var(--border-subtle); vertical-align: middle; }
.tbl tbody tr:hover { background: var(--ink-50); cursor: pointer; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.cell-strong { font-weight: 600; color: var(--fg-1); }
.cell-muted  { color: var(--fg-3); }
.cell-mono   { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 12.5px; }

/* ============ AVATARS ============ */
.av {
  width: 30px; height: 30px; border-radius: 999px;
  background: var(--plum-100); color: var(--plum-700);
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 11.5px;
  flex-shrink: 0;
}
.av-row { display: flex; align-items: center; gap: 10px; }
.av-row .nm { font-weight: 500; line-height: 1.2; }
.av-row .sub { color: var(--fg-3); font-size: 12px; }

/* ============ FORMS ============ */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12px; font-weight: 600; color: var(--fg-2); }
.field input, .field select, .field textarea {
  font-family: var(--font-sans); font-size: 13.5px;
  padding: 9px 12px; border: 1px solid var(--border-strong);
  border-radius: 6px; background: #fff; color: var(--fg-1);
  outline: none; transition: all var(--dur-base);
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--brand-burgundy);
  box-shadow: 0 0 0 3px rgba(111, 25, 71, 0.15);
}

/* ============ DRAWER / MODAL ============ */
.scrim {
  position: fixed; inset: 0; background: var(--bg-overlay);
  z-index: 50; animation: fade 200ms var(--ease-standard);
}
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: 560px;
  background: #fff; z-index: 51;
  display: flex; flex-direction: column;
  box-shadow: -16px 0 40px rgba(35, 31, 32, 0.18);
  animation: slideIn 260ms var(--ease-emphatic);
}
@keyframes fade { from { opacity: 0 } to { opacity: 1 } }
@keyframes slideIn { from { transform: translateX(40px); opacity: 0 } to { transform: translateX(0); opacity: 1 } }

/* ============ TIMELINE ============ */
.timeline { position: relative; padding-left: 24px; }
.timeline::before { content: ""; position: absolute; left: 6px; top: 4px; bottom: 4px; width: 2px; background: var(--ink-200); }
.tl-item { position: relative; padding-bottom: 16px; }
.tl-item::before {
  content: ""; position: absolute; left: -22px; top: 4px;
  width: 10px; height: 10px; border-radius: 999px;
  background: #fff; border: 2px solid var(--brand-burgundy);
}
.tl-item.done::before { background: var(--brand-burgundy); }
.tl-item .when { font-size: 11px; color: var(--fg-3); font-family: var(--font-mono); }
.tl-item .what { font-size: 13.5px; margin-top: 2px; }
.tl-item .who  { font-size: 12px; color: var(--fg-3); margin-top: 2px; }

/* ============ STAGE PIPELINE ============ */
.pipeline { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; min-width: 0; }
.stage {
  position: relative; padding: 12px 14px 12px 18px;
  background: #fff; border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md); overflow: hidden;
}
.stage::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
  background: var(--ink-300);
}
.stage.done::before { background: var(--success-500); }
.stage.current::before { background: var(--brand-burgundy); }
.stage .n { font-size: 10px; color: var(--fg-3); font-family: var(--font-mono); }
.stage .t { font-size: 13px; font-weight: 600; margin-top: 2px; }
.stage .s { font-size: 11.5px; color: var(--fg-3); margin-top: 2px; }

/* ============ MODAL ============ */
.modal {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: 520px; max-width: calc(100vw - 32px); max-height: calc(100vh - 64px);
  background: #fff; border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); z-index: 51;
  display: flex; flex-direction: column;
  animation: modalIn 220ms var(--ease-emphatic);
}
@keyframes modalIn { from { opacity: 0; transform: translate(-50%, -48%) scale(0.97) } to { opacity: 1; transform: translate(-50%, -50%) scale(1) } }
.modal-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  padding: 22px 24px 18px; border-bottom: 1px solid var(--border-subtle);
}
.modal-body {
  padding: 22px 24px; overflow-y: auto;
  display: flex; flex-direction: column; gap: 16px;
}
.modal-footer {
  display: flex; justify-content: flex-end; gap: 8px; padding-top: 4px;
  border-top: 1px solid var(--border-subtle); margin-top: 4px; padding-top: 16px;
}

/* ============ RING WATERMARK ============ */
.ring-watermark {
  position: absolute; pointer-events: none; opacity: 0.06; color: var(--brand-burgundy);
}

/* ============ HAMBURGER (hidden on desktop) ============ */
.hamburger {
  display: none; width: 36px; height: 36px; align-items: center; justify-content: center;
  background: transparent; border: 0; cursor: pointer; color: var(--fg-2);
  border-radius: 6px; flex-shrink: 0;
}
.hamburger:hover { background: var(--ink-100); }

/* ============ RESPONSIVE ============ */

/* helpers */
.resp-grid-4 { display: grid; }
.resp-grid-3 { display: grid; }
.resp-two-col { display: grid; }

@media (max-width: 768px) {
  /* Login panels */
  .login-hero { display: none !important; }
  .login-form-panel { width: 100% !important; padding: 40px 24px !important; }

  /* Sidebar — slide-in drawer */
  .sidebar {
    position: fixed; top: 0; bottom: 0; left: -260px;
    z-index: 100; transition: left 220ms ease;
    box-shadow: none;
  }
  .sidebar.mobile-open {
    left: 0;
    box-shadow: 8px 0 32px rgba(35,31,32,0.22);
  }

  /* Main area takes full width */
  .main { min-width: 0; width: 100%; }

  /* Topbar */
  .topbar { padding: 0 14px; height: 56px; gap: 8px; }
  .topbar .search { display: none; }
  .hamburger { display: flex; }

  /* Page */
  .page { padding: 20px 16px 56px; }
  .page-head { flex-direction: column; align-items: flex-start !important; gap: 12px !important; margin-bottom: 18px; }
  .page-title { font-size: 24px !important; }
  .page-sub { font-size: 13px; }

  /* Responsive grids */
  .resp-grid-4 { grid-template-columns: 1fr 1fr !important; }
  .resp-grid-3 { grid-template-columns: 1fr 1fr !important; }
  .resp-two-col { grid-template-columns: 1fr !important; }

  /* Tables — horizontal scroll */
  .card { overflow-x: auto; }
  .tbl { min-width: 580px; }

  /* Modals */
  .modal { width: calc(100vw - 24px) !important; }

  /* Drawers */
  .drawer { width: 100% !important; max-width: 380px; }
}

@media (max-width: 480px) {
  .resp-grid-4, .resp-grid-3 { grid-template-columns: 1fr !important; }
  .page { padding: 16px 12px 48px; }
  .page-title { font-size: 20px !important; }
  .topbar-actions .btn span { display: none; }
}
