/* ============================================================
   CRM LEG Technologies — Main Stylesheet
   Font: Source Sans Pro · Colors: LEG Technologies Brand
   ============================================================ */

/* ── Variables ────────────────────────────────────────────── */
:root {
  --primary:       #2ea3f2;
  --primary-dark:  #1a8dd4;
  --primary-light: #e6f4fd;
  --sidebar-width: 260px;
  --sidebar-bg:    #1a2332;
  --sidebar-text:  #8fa3b8;
  --sidebar-active:#2ea3f2;
  --topbar-h:      64px;
  --radius:        8px;
  --shadow:        0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md:     0 4px 6px -1px rgba(0,0,0,.1), 0 2px 4px -2px rgba(0,0,0,.1);
  --text-dark:     #32373c;
  --text-muted:    #6c757d;
}

/* ── Reset & Base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
body {
  font-family: 'Source Sans Pro', 'Open Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--text-dark);
}

/* ── Layout ───────────────────────────────────────────────── */
.crm-body { display: flex; min-height: 100vh; background: #f4f6f9; }

/* ── Sidebar ──────────────────────────────────────────────── */
.crm-sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  min-height: 100vh;
  position: fixed;
  top: 0; left: 0;
  display: flex;
  flex-direction: column;
  z-index: 1040;
  transition: transform .3s ease;
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,.07);
}
.brand-icon {
  width: 36px; height: 36px;
  background: var(--primary);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 18px;
  flex-shrink: 0;
}
.brand-text {
  color: #c8d6e5;
  font-size: 16px;
  font-weight: 400;
  margin-left: .5rem;
  letter-spacing: .01em;
}
.brand-text strong { color: white; font-weight: 700; }

.sidebar-nav { padding: .5rem 0; flex: 1; }
.nav-section { margin-bottom: .25rem; }
.nav-section-label {
  padding: .75rem 1.25rem .25rem;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: #4a6080;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .625rem 1.25rem;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 14px;
  font-weight: 400;
  border-radius: 6px;
  margin: 1px .5rem;
  transition: background .15s, color .15s;
}
.nav-item:hover { background: rgba(255,255,255,.06); color: #c8d6e5; }
.nav-item.active {
  background: rgba(46,163,242,.15);
  color: #2ea3f2;
}
.nav-item.active i { color: var(--sidebar-active); }
.nav-item i { font-size: 16px; flex-shrink: 0; width: 18px; text-align: center; }
.nav-badge {
  margin-left: auto;
  background: var(--primary);
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 10px;
}

.sidebar-footer {
  padding: 1rem;
  border-top: 1px solid rgba(255,255,255,.07);
}
.uf-indicator {
  display: flex;
  align-items: center;
  gap: .5rem;
  color: #8fa3b8;
  font-size: 12px;
  padding: .5rem .75rem;
  background: rgba(255,255,255,.04);
  border-radius: 6px;
}

/* ── Main Content ─────────────────────────────────────────── */
.crm-main {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  flex: 1;
}

/* ── Topbar ───────────────────────────────────────────────── */
.crm-topbar {
  height: var(--topbar-h);
  background: white;
  border-bottom: 1px solid #e4e8ed;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}
.topbar-left, .topbar-right { display: flex; align-items: center; gap: .5rem; }
.topbar-btn {
  color: #6c7d90;
  padding: .4rem .5rem;
  border-radius: 6px;
  transition: background .15s;
}
.topbar-btn:hover { background: #f0f4f8; color: var(--text-dark); }
.user-avatar-sm {
  width: 34px; height: 34px;
  background: var(--primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 12px;
  font-weight: 700;
  overflow: hidden;
}
.user-avatar-sm img { width: 100%; height: 100%; object-fit: cover; }
.notif-dot {
  width: 8px; height: 8px;
  background: #ef4444;
  border-radius: 50%;
  position: absolute;
  top: 4px; right: 4px;
  border: 1.5px solid white;
}
.notif-dropdown { width: 340px; max-height: 400px; overflow-y: auto; }

/* ── Content Area ─────────────────────────────────────────── */
.crm-content { flex: 1; padding: 0; }
.crm-footer {
  padding: .75rem 1.5rem;
  border-top: 1px solid #e4e8ed;
  background: white;
}

/* ── Page Header ──────────────────────────────────────────── */
.page-header {
  padding: 1.5rem 1.5rem 0;
  background: white;
  border-bottom: 1px solid #e4e8ed;
  margin-bottom: 1.5rem;
}
.page-title { font-size: 1.375rem; font-weight: 700; color: #1a2332; margin: 0; }
.page-subtitle { color: #6c7d90; font-size: 13px; margin: .15rem 0 1rem; }
.page-actions { display: flex; gap: .5rem; align-items: center; }
.page-body { padding: 0 1.5rem 1.5rem; }

/* ── Buttons ──────────────────────────────────────────────── */
.btn-primary {
  background-color: var(--primary);
  border-color: var(--primary);
  font-weight: 600;
}
.btn-primary:hover, .btn-primary:focus {
  background-color: var(--primary-dark);
  border-color: var(--primary-dark);
}
.btn-outline-primary {
  color: var(--primary);
  border-color: var(--primary);
}
.btn-outline-primary:hover {
  background-color: var(--primary);
  border-color: var(--primary);
}

/* ── KPI Cards ────────────────────────────────────────────── */
.kpi-card {
  background: white;
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: .75rem;
  position: relative;
  overflow: hidden;
  transition: box-shadow .2s;
}
.kpi-card:hover { box-shadow: var(--shadow-md); }
.kpi-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 4px; height: 100%;
}
.kpi-primary::before  { background: var(--primary); }
.kpi-success::before  { background: #10b981; }
.kpi-warning::before  { background: #f59e0b; }
.kpi-danger::before   { background: #ef4444; }
.kpi-info::before     { background: #06b6d4; }

.kpi-icon {
  width: 44px; height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  background: var(--primary-light);
  color: var(--primary);
}
.kpi-primary .kpi-icon { background: var(--primary-light); color: var(--primary); }
.kpi-success .kpi-icon { background: #d1fae5; color: #065f46; }
.kpi-warning .kpi-icon { background: #fef3c7; color: #92400e; }
.kpi-danger .kpi-icon  { background: #fee2e2; color: #991b1b; }
.kpi-info .kpi-icon    { background: #cffafe; color: #0e7490; }

.kpi-value { font-size: 1.75rem; font-weight: 700; color: #1a2332; line-height: 1; }
.kpi-label { font-size: 13px; color: #6c7d90; margin-top: .15rem; }
.kpi-link  { font-size: 12px; color: var(--primary); text-decoration: none; margin-top: auto; }
.kpi-link:hover { text-decoration: underline; }

/* ── Cards ────────────────────────────────────────────────── */
.card {
  border: 1px solid #e4e8ed;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid #e4e8ed;
  background: white;
  border-radius: var(--radius) var(--radius) 0 0;
}
.card-title { font-size: 14px; font-weight: 600; color: #1a2332; }
.card-body  { padding: 1.25rem; background: white; }

/* ── Pipeline ─────────────────────────────────────────────── */
.pipeline-row {
  display: flex;
  align-items: center;
  padding: .625rem 1.25rem;
  border-bottom: 1px solid #f4f6f9;
  gap: .75rem;
}
.pipeline-stage { min-width: 140px; }
.pipeline-count { min-width: 80px; font-size: 12px; }

/* ── Activity Feed ────────────────────────────────────────── */
.activity-feed { padding: .5rem 0; }
.activity-item {
  display: flex;
  gap: .75rem;
  padding: .625rem 1.25rem;
  border-bottom: 1px solid #f8fafc;
}
.activity-icon {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  flex-shrink: 0;
  background: #f0f4f8;
  color: #6c7d90;
}
.activity-text { font-size: 13px; }
.activity-text a { color: var(--text-dark); text-decoration: none; }
.activity-text a:hover { color: var(--primary); }
.activity-meta { font-size: 11px; color: #a0b0c0; margin-top: 1px; }

/* ── UF Card ──────────────────────────────────────────────── */
.uf-card {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  padding: .75rem 1rem;
  background: var(--primary-light);
  border: 1px solid #b8dff8;
  border-radius: var(--radius);
}
.uf-label  { font-size: 10px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--primary); }
.uf-value  { font-size: 1.25rem; font-weight: 700; color: #1a2332; }
.uf-date   { font-size: 11px; color: #6c7d90; }

/* ── Tables ───────────────────────────────────────────────── */
.table > :not(caption) > * > * { padding: .625rem .875rem; }
.table thead th {
  background: #f4f6f9;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: #6c7d90;
  border-bottom: 2px solid #e4e8ed;
}
.table tbody tr:hover { background: #f8fafc; }

/* ── Filters Bar ──────────────────────────────────────────── */
.filters-bar {
  display: flex;
  gap: .75rem;
  align-items: center;
  flex-wrap: wrap;
  padding: 1rem 1.5rem;
  background: white;
  border-bottom: 1px solid #e4e8ed;
  margin-bottom: 1.5rem;
}
.search-input {
  position: relative;
  flex: 1;
  min-width: 200px;
  max-width: 400px;
}
.search-input i {
  position: absolute;
  left: .75rem; top: 50%;
  transform: translateY(-50%);
  color: #a0b0c0;
}
.search-input input { padding-left: 2.25rem; }

/* ── Status Badges ────────────────────────────────────────── */
.badge { font-weight: 600; font-size: 11px; }

/* ── Forms ────────────────────────────────────────────────── */
.form-label { font-weight: 600; font-size: 13px; color: #32373c; }
.form-control, .form-select { font-size: 14px; border-color: #d0d7de; }
.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(46,163,242,.15);
}
.form-section { margin-bottom: 1.5rem; }
.form-section-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: #6c7d90;
  padding-bottom: .5rem;
  border-bottom: 1px solid #e4e8ed;
  margin-bottom: 1rem;
}

/* ── Nav Tabs (settings) ──────────────────────────────────── */
.nav-tabs .nav-link {
  color: #6c7d90;
  font-weight: 600;
  font-size: 14px;
  border: none;
  border-bottom: 2px solid transparent;
  padding: .5rem 1rem .75rem;
}
.nav-tabs .nav-link:hover { color: var(--primary); background: none; }
.nav-tabs .nav-link.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  background: none;
}

/* ── Quoter Items ─────────────────────────────────────────── */
.quoter-item {
  background: white;
  border: 1px solid #e4e8ed;
  border-radius: 6px;
  padding: .875rem;
  margin-bottom: .5rem;
  position: relative;
}
.quoter-item.section-item { background: var(--primary-light); border-color: var(--primary); }
.quoter-totals {
  background: white;
  border: 1px solid #e4e8ed;
  border-radius: 6px;
  padding: 1rem;
  margin-top: 1rem;
  float: right;
  min-width: 280px;
}

/* ── Login Page ───────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  background: linear-gradient(135deg, #1a2332 0%, #1e3a5f 50%, #2ea3f2 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.login-container { width: 100%; max-width: 420px; }
.login-card {
  background: white;
  border-radius: 16px;
  padding: 2.5rem;
  box-shadow: 0 25px 50px rgba(0,0,0,.25);
}
.login-brand { text-align: center; margin-bottom: 2rem; }
.login-logo {
  width: 64px; height: 64px;
  background: var(--primary);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 30px;
  color: white;
  margin: 0 auto .75rem;
  box-shadow: 0 8px 24px rgba(46,163,242,.4);
}
.login-title { font-size: 1.5rem; font-weight: 400; color: #1a2332; margin: 0; }
.login-title strong { font-weight: 700; }
.login-subtitle { color: #6c7d90; font-size: 14px; margin: .25rem 0 0; }
.btn-login { height: 44px; font-weight: 700; }
.login-divider {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin: 1.25rem 0;
  color: #a0b0c0;
  font-size: 12px;
}
.login-divider::before,
.login-divider::after { content: ''; flex: 1; height: 1px; background: #e4e8ed; }
.btn-ms365 {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .75rem;
  background: white;
  color: #1a2332;
  border: 1.5px solid #e4e8ed;
  border-radius: 8px;
  padding: .625rem;
  font-weight: 600;
  text-decoration: none;
  transition: background .15s;
}
.btn-ms365:hover { background: #f4f6f9; color: #1a2332; }
.login-footer-text { text-align: center; color: #a0b0c0; font-size: 12px; margin-top: 1.5rem; margin-bottom: 0; }

/* ── Empty State ──────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  color: #a0b0c0;
}
.empty-state i { display: block; font-size: 2.5rem; margin-bottom: .75rem; }

/* ── Sidebar Overlay (mobile) ─────────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 1039;
}

/* ── Pagination ───────────────────────────────────────────── */
.pagination .page-link { color: var(--primary); border-color: #e4e8ed; }
.pagination .active .page-link { background: var(--primary); border-color: var(--primary); }

/* ── Links ────────────────────────────────────────────────── */
a { color: var(--primary); }
a:hover { color: var(--primary-dark); }

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 1199px) {
  .crm-sidebar { transform: translateX(-100%); }
  .crm-sidebar.open { transform: translateX(0); }
  .sidebar-overlay.open { display: block; }
  .crm-main { margin-left: 0; }
}

@media (max-width: 575px) {
  .page-header { padding: 1rem 1rem 0; }
  .page-body { padding: 0 1rem 1rem; }
  .filters-bar { padding: .75rem 1rem; }
  .crm-topbar { padding: 0 1rem; }
}

/* ── Print / PDF ──────────────────────────────────────────── */
@media print {
  .crm-sidebar, .crm-topbar, .crm-footer, .no-print { display: none !important; }
  .crm-main { margin-left: 0; }
  .crm-content { padding: 0; }
}
