/* ============================================================
   Sabea Broker Portal — Contacts Module
   Scoped under .ct-* to avoid clashing with existing styles.
   Reuses CSS vars from index.html + patterns from crm.css.
   ============================================================ */

.ct-header {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 24px;
  margin-bottom: 18px; flex-wrap: wrap;
}
.ct-title {
  font-family: 'Playfair Display', serif;
  font-size: 26px; font-weight: 700;
  color: var(--navy); line-height: 1;
}
.ct-sub { font-size: 13px; color: var(--mu); margin-top: 4px; }
.ct-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.ct-filterbar {
  background: #fff; border: 1.5px solid var(--br);
  border-radius: 12px; padding: 12px 14px;
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 12px; flex-wrap: wrap;
}
.ct-search {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg); padding: 6px 12px; border-radius: 8px;
  border: 1.5px solid var(--br); min-width: 280px;
}
.ct-search svg { color: var(--mu); flex: none; }
.ct-search input {
  border: 0; outline: 0; background: transparent;
  font-family: inherit; font-size: 13px; width: 100%;
  color: var(--navy);
}

.ct-bulkbar {
  background: var(--gold-l); border: 1.5px solid var(--gold-b);
  border-radius: 10px; padding: 10px 14px;
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 12px; flex-wrap: wrap;
  font-size: 13px; color: var(--navy);
}

.ct-tableview {
  background: #fff; border: 1.5px solid var(--br); border-radius: 12px;
  overflow: hidden;
}
.ct-table-scroll { overflow-x: auto; }
.ct-table {
  width: 100%; border-collapse: collapse; font-size: 13px;
}
.ct-table thead th {
  text-align: left; font-weight: 600; color: var(--mu);
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em;
  padding: 12px 14px; border-bottom: 1.5px solid var(--br);
  background: var(--bg);
  position: sticky; top: 0;
}
.ct-table tbody tr { border-bottom: 1px solid var(--br); transition: background .12s; }
.ct-table tbody tr:hover { background: var(--bg); }
.ct-table tbody tr.is-optout { opacity: .55; background: #f5f3ec; }
.ct-table tbody td { padding: 11px 14px; vertical-align: middle; }
.ct-table .ct-name { font-weight: 600; color: var(--navy); }
.ct-empty td { text-align: center; padding: 56px; color: var(--mu); }

.ct-tag {
  display: inline-block; padding: 2px 8px; border-radius: 12px;
  font-size: 10.5px; font-weight: 600; letter-spacing: .02em;
  background: var(--gold-l); color: #6b5820; border: 1px solid var(--gold-b);
  margin: 1px 2px;
}
.ct-tag--source-lead   { background: #d9e3f7; color: #1F4AA8; border-color: #b3c4e8; }
.ct-tag--source-member { background: var(--navy); color: #fff; border-color: var(--navy); }
.ct-tag--source-manual { background: #eaeaea; color: #555; border-color: #d0d0d0; }
.ct-tag--source-csv    { background: #d6ead9; color: #1E7D53; border-color: #b0d4b6; }

.ct-row-actions { display: flex; gap: 4px; justify-content: flex-end; }
.ct-row-btn {
  background: transparent; border: 0; cursor: pointer;
  color: var(--mu); padding: 4px 6px; border-radius: 4px;
  font-size: 14px;
}
.ct-row-btn:hover { background: var(--bg); color: var(--navy); }

.ct-pagination {
  display: flex; align-items: center; justify-content: center; gap: 12px;
  margin-top: 16px; font-size: 13px; color: var(--mu);
}

/* --- Drawer (contact detail) --- */
.ct-drawer { position: fixed; inset: 0; z-index: 80; pointer-events: none; }
.ct-drawer[aria-hidden="false"] { pointer-events: auto; }
.ct-drawer-backdrop {
  position: absolute; inset: 0; background: rgba(18,21,61,.45);
  opacity: 0; transition: opacity .2s;
}
.ct-drawer[aria-hidden="false"] .ct-drawer-backdrop { opacity: 1; }
.ct-drawer-panel {
  position: absolute; top: 0; right: 0; bottom: 0;
  width: 100%; max-width: 480px;
  background: var(--bg);
  box-shadow: -24px 0 60px rgba(18,21,61,.2);
  transform: translateX(100%); transition: transform .25s ease;
  display: flex; flex-direction: column;
}
.ct-drawer[aria-hidden="false"] .ct-drawer-panel { transform: translateX(0); }
.ct-drawer-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
  padding: 20px 24px 16px; background: var(--navy); color: #fff;
}
.ct-drawer-head h2 {
  font-family: 'Playfair Display', serif; font-weight: 700;
  margin: 0; font-size: 20px; line-height: 1.2;
}
.ct-drawer-head p { margin: 4px 0 0; font-size: 12px; color: rgba(255,255,255,.7); }
.ct-drawer-close {
  border: 0; background: rgba(255,255,255,.1); color: #fff;
  width: 32px; height: 32px; border-radius: 8px;
  cursor: pointer; font-size: 16px; flex: none;
}
.ct-drawer-close:hover { background: rgba(255,255,255,.2); }
.ct-drawer-body { flex: 1; overflow-y: auto; padding: 20px 24px 16px; }

.ct-field { margin-bottom: 12px; }
.ct-field label {
  display: block; font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .06em;
  color: var(--mu); margin-bottom: 4px;
}
.ct-field input,
.ct-field textarea {
  width: 100%; font-family: inherit; font-size: 13px;
  border: 1.5px solid var(--br); border-radius: 8px;
  padding: 8px 10px; background: #fff; color: var(--navy);
}
.ct-field input:focus,
.ct-field textarea:focus {
  outline: 2px solid var(--gold-l); outline-offset: 1px; border-color: var(--gold);
}

.ct-drawer-foot {
  display: flex; gap: 8px; align-items: center;
  padding: 12px 24px; background: #fff; border-top: 1.5px solid var(--br);
}

/* --- CSV Import Modal --- */
.ct-modal { position: fixed; inset: 0; z-index: 90; display: flex; align-items: center; justify-content: center; }
.ct-modal-backdrop { position: absolute; inset: 0; background: rgba(18,21,61,.5); }
.ct-modal-panel {
  position: relative; background: var(--bg);
  border-radius: 16px; box-shadow: 0 40px 80px rgba(18,21,61,.35);
  width: 640px; max-width: calc(100vw - 32px); max-height: calc(100vh - 32px);
  display: flex; flex-direction: column; overflow: hidden;
}
.ct-modal-head {
  padding: 18px 24px; background: var(--navy); color: #fff;
  display: flex; align-items: center; justify-content: space-between;
}
.ct-modal-head h2 {
  font-family: 'Playfair Display', serif; font-weight: 700;
  margin: 0; font-size: 20px;
}
.ct-modal-body { padding: 20px 24px; overflow-y: auto; flex: 1; }
.ct-modal-foot {
  padding: 12px 24px; background: #fff; border-top: 1.5px solid var(--br);
  display: flex; gap: 8px;
}

.ct-upload {
  border: 2px dashed var(--gold-b); border-radius: 10px;
  padding: 30px; text-align: center; background: #fff;
}

.ct-mapping-row {
  display: grid; grid-template-columns: 1fr auto 1fr;
  gap: 10px; align-items: center; margin-bottom: 8px;
  padding: 8px 12px; background: #fff;
  border: 1px solid var(--br); border-radius: 8px;
}
.ct-mapping-row .col {
  font-family: monospace; font-size: 12px; color: var(--navy); font-weight: 600;
}
.ct-mapping-row .arrow { color: var(--mu); }
.ct-mapping-row select {
  font-family: inherit; font-size: 12px;
  border: 1.5px solid var(--br); border-radius: 6px;
  padding: 4px 8px; background: #fff; color: var(--navy);
}

.ct-import-summary {
  background: #fff; border: 1.5px solid var(--br);
  border-radius: 10px; padding: 16px;
}
.ct-import-summary .row {
  display: flex; justify-content: space-between;
  padding: 6px 0; font-size: 13px;
}
.ct-import-summary .row + .row { border-top: 1px solid var(--br); }
.ct-import-summary strong { color: var(--navy); }

@media (max-width: 900px) {
  .ct-search { min-width: 0; flex: 1; }
  .ct-drawer-panel { max-width: 100%; }
  .ct-modal-panel { width: calc(100vw - 16px); }
}
