/* =====================================================================
   Webnity Portal — application styles
   Light, plain and fast. Layered on top of Bootstrap 5.
   ===================================================================== */

:root {
  --wp-bg:        #f4f6f9;
  --wp-surface:   #ffffff;
  --wp-border:    #e3e7ee;
  --wp-text:      #1f2733;
  --wp-muted:     #6b7686;
  --wp-primary:   #0d6efd;
  --wp-sidebar:   #ffffff;
  --wp-topbar-h:  56px;
  --wp-sidebar-w: 236px;
  --wp-radius:    10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--wp-bg);
  color: var(--wp-text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

a { text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------------------------------------------------------------- top bar */

.topbar {
  position: fixed;
  inset: 0 0 auto 0;
  height: var(--wp-topbar-h);
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: 0 .75rem;
  background: var(--wp-surface);
  border-bottom: 1px solid var(--wp-border);
  z-index: 1040;
}

.topbar-toggle { color: var(--wp-text); font-size: 1.35rem; padding: .25rem .5rem; }
.topbar-toggle:focus { box-shadow: none; }

.topbar-brand {
  display: flex; align-items: center; gap: .5rem;
  font-weight: 600; color: var(--wp-text); white-space: nowrap;
}
.topbar-brand:hover { text-decoration: none; color: var(--wp-text); }

.topbar-mark {
  width: 28px; height: 28px; border-radius: 7px;
  background: var(--wp-primary); color: #fff;
  display: grid; place-items: center; font-weight: 700; font-size: .9rem;
}

.topbar-search { position: relative; flex: 1 1 420px; max-width: 460px; margin-left: .75rem; }
.topbar-search form { position: relative; }
.topbar-search .bi-search {
  position: absolute; left: .7rem; top: 50%; transform: translateY(-50%);
  color: var(--wp-muted); font-size: .9rem; pointer-events: none;
}
.topbar-search .form-control {
  padding-left: 2.1rem; height: 36px; font-size: .875rem;
  background: var(--wp-bg); border-color: transparent;
}
.topbar-search .form-control:focus { background: #fff; border-color: var(--wp-primary); box-shadow: none; }

.search-results {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0;
  background: #fff; border: 1px solid var(--wp-border); border-radius: var(--wp-radius);
  box-shadow: 0 12px 28px rgba(16, 24, 40, .12);
  max-height: 60vh; overflow-y: auto; z-index: 1050;
}
.search-results a {
  display: block; padding: .55rem .8rem; color: var(--wp-text); border-bottom: 1px solid #f1f3f7;
}
.search-results a:last-child { border-bottom: 0; }
.search-results a:hover, .search-results a.active { background: #f5f8ff; text-decoration: none; }
.search-results .sr-title { font-weight: 600; }
.search-results .sr-meta { font-size: .78rem; color: var(--wp-muted); }
.search-results .sr-empty { padding: .8rem; color: var(--wp-muted); }

.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: .35rem; }

.btn-icon {
  width: 36px; height: 36px; border-radius: 8px; border: 0; background: transparent;
  color: var(--wp-text); font-size: 1.05rem; display: grid; place-items: center;
}
.btn-icon:hover { background: var(--wp-bg); }

.notif-dot {
  position: absolute; top: 2px; right: 2px; min-width: 16px; height: 16px;
  padding: 0 4px; border-radius: 8px; background: #dc3545; color: #fff;
  font-size: .65rem; font-weight: 700; line-height: 16px; text-align: center;
}

.notif-menu { width: 330px; padding: 0; max-height: 70vh; overflow-y: auto; }
.notif-head { display: flex; justify-content: space-between; align-items: center; padding: .65rem .85rem; border-bottom: 1px solid var(--wp-border); }
.notif-item { display: block; padding: .6rem .85rem; border-bottom: 1px solid #f1f3f7; color: var(--wp-text); }
.notif-item:hover { background: #f7f9fc; text-decoration: none; }
.notif-item.unread { background: #f2f7ff; }
.notif-item.unread .notif-title::before {
  content: ''; display: inline-block; width: 7px; height: 7px; border-radius: 50%;
  background: var(--wp-primary); margin-right: 6px; vertical-align: middle;
}
.notif-title { font-weight: 600; font-size: .85rem; }
.notif-msg   { font-size: .8rem; color: var(--wp-muted); }
.notif-time  { font-size: .72rem; color: #9aa3b0; margin-top: 2px; }
.notif-empty { padding: 1.5rem .85rem; text-align: center; color: var(--wp-muted); }
.notif-all   { display: block; padding: .6rem; text-align: center; font-size: .82rem; border-top: 1px solid var(--wp-border); }

.btn-user { display: flex; align-items: center; border: 0; background: transparent; padding: .25rem .4rem; border-radius: 8px; }
.btn-user:hover { background: var(--wp-bg); }
.btn-user::after { margin-left: .35rem; }

.avatar {
  width: 30px; height: 30px; border-radius: 50%; color: #fff;
  display: inline-grid; place-items: center; font-size: .75rem; font-weight: 700;
  flex: 0 0 auto;
}
.avatar-sm { width: 24px; height: 24px; font-size: .65rem; }
.avatar-lg { width: 60px; height: 60px; font-size: 1.3rem; }

/* ---------------------------------------------------------------- layout */

.layout { display: flex; padding-top: var(--wp-topbar-h); min-height: 100vh; }

.sidebar {
  position: fixed; top: var(--wp-topbar-h); bottom: 0; left: 0;
  width: var(--wp-sidebar-w);
  background: var(--wp-sidebar);
  border-right: 1px solid var(--wp-border);
  overflow-y: auto;
  z-index: 1030;
}
.sidebar-offcanvas { width: 260px; }

.content {
  flex: 1 1 auto;
  min-width: 0;
  padding: 1.15rem 1.25rem 3rem;
}
@media (min-width: 992px) { .content { margin-left: var(--wp-sidebar-w); } }

/* ------------------------------------------------------------- side nav */

.sidenav { padding: .75rem .6rem 2rem; display: flex; flex-direction: column; min-height: 100%; }
.sidenav-label {
  font-size: .68rem; text-transform: uppercase; letter-spacing: .06em;
  color: #99a2b0; font-weight: 700; padding: .9rem .65rem .3rem;
}
.sidenav-list { list-style: none; margin: 0; padding: 0; }
.sidenav-link {
  display: flex; align-items: center; gap: .6rem;
  padding: .46rem .65rem; border-radius: 8px;
  color: #46505f; font-size: .87rem; font-weight: 500;
}
.sidenav-link:hover { background: #f2f5fa; color: var(--wp-text); text-decoration: none; }
.sidenav-link.active { background: #e8f0fe; color: var(--wp-primary); font-weight: 600; }
.sidenav-link i { font-size: 1rem; width: 18px; text-align: center; flex: 0 0 auto; }
.sidenav-foot { margin-top: auto; padding: 1rem .65rem 0; }

/* --------------------------------------------------------- page heading */

.page-head {
  display: flex; flex-wrap: wrap; gap: .75rem;
  align-items: flex-start; justify-content: space-between;
  margin-bottom: 1rem;
}
.page-head h1 { font-size: 1.35rem; font-weight: 650; margin: 0; }
.page-sub { margin: .2rem 0 0; color: var(--wp-muted); font-size: .85rem; }
.page-actions { display: flex; flex-wrap: wrap; gap: .4rem; }

/* -------------------------------------------------------------- surfaces */

.card {
  background: var(--wp-surface);
  border: 1px solid var(--wp-border);
  border-radius: var(--wp-radius);
  box-shadow: 0 1px 2px rgba(16, 24, 40, .04);
}
.card + .card { margin-top: 1rem; }
.card-header {
  background: transparent; border-bottom: 1px solid var(--wp-border);
  padding: .7rem 1rem; font-weight: 600; font-size: .92rem;
  display: flex; align-items: center; justify-content: space-between; gap: .5rem;
}
.card-body { padding: 1rem; }

.empty-state { border-style: dashed; }

/* ------------------------------------------------------------ stat cards */

.stat-grid {
  display: grid; gap: .75rem;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  margin-bottom: 1rem;
}
.stat {
  background: var(--wp-surface); border: 1px solid var(--wp-border);
  border-radius: var(--wp-radius); padding: .8rem .9rem;
  display: block; color: inherit;
}
a.stat:hover { text-decoration: none; border-color: #c9d6ec; box-shadow: 0 2px 8px rgba(16,24,40,.06); }
.stat-label { font-size: .74rem; text-transform: uppercase; letter-spacing: .04em; color: var(--wp-muted); font-weight: 600; }
.stat-value { font-size: 1.6rem; font-weight: 650; line-height: 1.2; margin-top: .15rem; }
.stat-note  { font-size: .76rem; color: var(--wp-muted); }
.stat.is-danger  .stat-value { color: #dc3545; }
.stat.is-warning .stat-value { color: #b8730d; }
.stat.is-success .stat-value { color: #146c43; }

/* ---------------------------------------------------------------- tables */

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { margin: 0; font-size: .865rem; }
.table > :not(caption) > * > * { padding: .58rem .75rem; }
.table thead th {
  background: #fafbfd; border-bottom: 1px solid var(--wp-border);
  font-size: .74rem; text-transform: uppercase; letter-spacing: .04em;
  color: var(--wp-muted); font-weight: 700; white-space: nowrap;
}
.table tbody tr:hover { background: #fafcff; }
.table td { vertical-align: middle; }
.table .nowrap { white-space: nowrap; }

.card > .table-wrap > .table > thead th:first-child,
.card > .table-wrap > .table > tbody td:first-child { padding-left: 1rem; }
.card > .table-wrap > .table > thead th:last-child,
.card > .table-wrap > .table > tbody td:last-child { padding-right: 1rem; }

.table-foot {
  display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; justify-content: space-between;
  padding: .6rem 1rem; border-top: 1px solid var(--wp-border); font-size: .82rem; color: var(--wp-muted);
}

.sort-link { color: inherit; }
.sort-link:hover { color: var(--wp-primary); text-decoration: none; }

/* ---------------------------------------------------------------- badges */

.badge-soft {
  display: inline-block; padding: .18rem .5rem; border-radius: 999px;
  font-size: .74rem; font-weight: 600; line-height: 1.35;
  color: var(--c, #6c757d);
  background: color-mix(in srgb, var(--c, #6c757d) 12%, #fff);
  border: 1px solid color-mix(in srgb, var(--c, #6c757d) 26%, #fff);
  white-space: nowrap;
}
@supports not (color: color-mix(in srgb, red 10%, white)) {
  .badge-soft { background: #f1f3f5; border-color: #dee2e6; }
}

.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--c, #6c757d); }

.overdue { color: #dc3545; font-weight: 600; }
.due-today { color: #b8730d; font-weight: 600; }

/* ---------------------------------------------------------------- forms */

.form-label { font-size: .82rem; font-weight: 600; margin-bottom: .3rem; color: #3c4655; }
.form-control, .form-select {
  font-size: .875rem; border-color: #d7dde7; border-radius: 8px;
  padding: .48rem .7rem; background-color: #fdfdfe;
}
.form-control:hover:not(:focus), .form-select:hover:not(:focus) { border-color: #c2cbd9; }
.form-control:focus, .form-select:focus {
  border-color: var(--wp-primary); background-color: #fff;
  box-shadow: 0 0 0 .18rem rgba(13, 110, 253, .12);
}
.form-control::placeholder { color: #aab3c0; }
.form-control-lg, .form-select-lg { font-size: .95rem; padding: .6rem .8rem; border-radius: 9px; }
.form-text { font-size: .78rem; color: var(--wp-muted); }
textarea.form-control { min-height: 90px; }

.input-group-text {
  background: #f5f7fb; border-color: #d7dde7; color: #8a94a3;
  border-radius: 8px 0 0 8px; padding: .48rem .65rem; font-size: .85rem;
}
.input-group > .form-control { border-radius: 0 8px 8px 0; }
.input-group:focus-within .input-group-text { border-color: var(--wp-primary); color: var(--wp-primary); }

.form-section { padding: 1.4rem 1.5rem; border-bottom: 1px solid var(--wp-border); }
.form-section:last-child { border-bottom: 0; }
.form-section > h2 { font-size: .95rem; font-weight: 650; margin: 0 0 .85rem; }

/* Section heading with a soft icon tile */
.section-head { display: flex; gap: .8rem; align-items: flex-start; margin-bottom: 1.15rem; }
.section-icon {
  width: 38px; height: 38px; flex: 0 0 auto;
  border-radius: 10px; display: grid; place-items: center;
  background: #eaf1ff; color: var(--wp-primary); font-size: 1.05rem;
}
.section-icon.icon-purple { background: #f1ecfd; color: #6f42c1; }
.section-icon.icon-green  { background: #e7f6ee; color: #198754; }
.section-head h2 { font-size: 1rem; font-weight: 650; margin: 0; letter-spacing: -.01em; }
.section-head p  { margin: .12rem 0 0; font-size: .82rem; color: var(--wp-muted); }

/* Light rule between field groups inside one section */
.field-divider { height: 1px; background: var(--wp-border); margin: 1.25rem 0; opacity: .7; }

/* Sticky action bar at the foot of a form card */
.form-actions {
  position: sticky; bottom: 0; z-index: 5;
  display: flex; flex-wrap: wrap; gap: .6rem; align-items: center;
  padding: .9rem 1.5rem;
  background: #fff;
  border-top: 1px solid var(--wp-border);
  border-radius: 0 0 var(--wp-radius) var(--wp-radius);
  box-shadow: 0 -6px 16px rgba(16, 24, 40, .05);
}
.form-actions .spacer { margin-left: auto; }
.form-actions .hint { font-size: .8rem; color: var(--wp-muted); }

.filter-bar { display: flex; flex-wrap: wrap; gap: .5rem; align-items: flex-end; }
.filter-bar .form-control, .filter-bar .form-select { min-width: 140px; }

.required::after { content: ' *'; color: #dc3545; }

/* -------------------------------------------------------------- timeline */

.timeline { list-style: none; margin: 0; padding: 0 0 0 .5rem; position: relative; }
.timeline::before {
  content: ''; position: absolute; left: 15px; top: 6px; bottom: 6px;
  width: 2px; background: #e6eaf1;
}
.timeline-item { position: relative; padding: 0 0 1.1rem 2.4rem; }
.timeline-item:last-child { padding-bottom: 0; }
.timeline-icon {
  position: absolute; left: 0; top: 0;
  width: 32px; height: 32px; border-radius: 50%;
  display: grid; place-items: center;
  background: #fff; border: 2px solid #e6eaf1; color: var(--wp-muted); font-size: .85rem;
}
.timeline-item.is-call     .timeline-icon { border-color: #b6d4fe; color: #0d6efd; }
.timeline-item.is-email    .timeline-icon { border-color: #b9e6d8; color: #198754; }
.timeline-item.is-meeting  .timeline-icon { border-color: #ffe0b2; color: #fd7e14; }
.timeline-item.is-note     .timeline-icon { border-color: #e2d9f3; color: #6f42c1; }
.timeline-head { display: flex; flex-wrap: wrap; gap: .4rem; align-items: baseline; }
.timeline-when { font-weight: 600; font-size: .85rem; }
.timeline-who  { color: var(--wp-muted); font-size: .8rem; }
.timeline-body {
  margin-top: .35rem; padding: .55rem .7rem; background: #f8fafc;
  border: 1px solid #eef1f6; border-radius: 8px; font-size: .86rem; white-space: pre-wrap;
}
.timeline-meta { margin-top: .35rem; font-size: .78rem; color: var(--wp-muted); display: flex; flex-wrap: wrap; gap: .75rem; }

/* ------------------------------------------------------------ lead views */

.detail-list { margin: 0; }
.detail-list > div { display: flex; gap: .75rem; padding: .35rem 0; border-bottom: 1px dashed #eef1f6; }
.detail-list > div:last-child { border-bottom: 0; }
.detail-list dt { flex: 0 0 40%; color: var(--wp-muted); font-weight: 500; font-size: .82rem; margin: 0; }
.detail-list dd { flex: 1 1 auto; margin: 0; font-size: .87rem; word-break: break-word; }

.lead-title { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.lead-meta { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; color: var(--wp-muted); font-size: .85rem; }
.lead-meta .sep { color: #ccd2dc; }

.pipeline { display: grid; gap: .4rem; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.pipeline-item {
  border: 1px solid var(--wp-border); border-radius: 8px; padding: .5rem .6rem;
  border-left: 4px solid var(--c, #6c757d); background: #fff; color: inherit; display: block;
}
.pipeline-item:hover { text-decoration: none; background: #fafcff; }
.pipeline-name { font-size: .78rem; color: var(--wp-muted); }
.pipeline-count { font-size: 1.15rem; font-weight: 650; }

/* --------------------------------------------------------------- helpers */

.text-muted { color: var(--wp-muted) !important; }
.small-muted { font-size: .78rem; color: var(--wp-muted); }
.hr-light { border-top: 1px solid var(--wp-border); margin: .85rem 0; }
.gap-row { display: flex; flex-wrap: wrap; gap: .4rem; }
.link-plain { color: var(--wp-text); }
.link-plain:hover { color: var(--wp-primary); }
.w-min { width: 1%; white-space: nowrap; }

.btn { font-size: .865rem; }
.btn-sm { font-size: .8rem; }
.dropdown-item { font-size: .875rem; }
.dropdown-menu { font-size: .875rem; border-color: var(--wp-border); box-shadow: 0 8px 24px rgba(16,24,40,.1); }

.alert { border-radius: var(--wp-radius); font-size: .875rem; }

/* --------------------------------------------------------------- login */

.login-page {
  min-height: 100vh; display: grid; place-items: center;
  background: linear-gradient(180deg, #f4f6f9 0%, #eaeff7 100%); padding: 1.5rem;
}
.login-card { width: 100%; max-width: 400px; }
.login-mark {
  width: 48px; height: 48px; border-radius: 12px; background: var(--wp-primary);
  color: #fff; display: grid; place-items: center; font-size: 1.35rem; font-weight: 700;
  margin: 0 auto .75rem;
}

/* --------------------------------------------------------------- print */

@media print {
  .topbar, .sidebar, .page-actions, .filter-bar, .table-foot { display: none !important; }
  .content { margin: 0; padding: 0; }
  .layout { padding-top: 0; }
  .card { border: 1px solid #ccc; box-shadow: none; }
}
