/**
 * CT Sharks — Design system (Apple-inspired)
 * Tokens: colors, spacing, radii, shadows, typography
 * Components: buttons, cards, tables, badges, alerts, modals, states
 */

/* ---------------------------------------------------------------------------
   TOKENS
   --------------------------------------------------------------------------- */
:root {
  /* Colors — neutral, minimal */
  --ct-gray-50: #fafafa;
  --ct-gray-100: #f5f5f5;
  --ct-gray-200: #eeeeee;
  --ct-gray-300: #e0e0e0;
  --ct-gray-400: #bdbdbd;
  --ct-gray-500: #9e9e9e;
  --ct-gray-600: #757575;
  --ct-gray-700: #616161;
  --ct-gray-800: #424242;
  --ct-gray-900: #212121;

  --ct-primary: #0071e3;
  --ct-primary-hover: #0077ed;
  --ct-success: #34c759;
  --ct-warning: #ff9500;
  --ct-danger: #ff3b30;

  /* Spacing — 8px grid */
  --ct-space-1: 0.25rem;   /* 4px */
  --ct-space-2: 0.5rem;    /* 8px */
  --ct-space-3: 0.75rem;   /* 12px */
  --ct-space-4: 1rem;      /* 16px */
  --ct-space-5: 1.25rem;   /* 20px */
  --ct-space-6: 1.5rem;    /* 24px */
  --ct-space-8: 2rem;      /* 32px */
  --ct-space-10: 2.5rem;   /* 40px */
  --ct-space-12: 3rem;     /* 48px */

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

  /* Shadows — soft */
  --ct-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --ct-shadow-md: 0 4px 12px rgba(0, 0, 0, 0.06);
  --ct-shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.08);

  /* Typography */
  --ct-font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --ct-font-size-xs: 0.75rem;
  --ct-font-size-sm: 0.875rem;
  --ct-font-size-base: 1rem;
  --ct-font-size-lg: 1.125rem;
  --ct-font-size-xl: 1.25rem;
  --ct-line-height-tight: 1.25;
  --ct-line-height-normal: 1.5;
}

/* ---------------------------------------------------------------------------
   BASE
   --------------------------------------------------------------------------- */
body {
  font-family: var(--ct-font-sans);
  font-size: var(--ct-font-size-base);
  line-height: var(--ct-line-height-normal);
  color: var(--ct-gray-900);
  background-color: var(--ct-gray-100);
  -webkit-font-smoothing: antialiased;
}

/* ---------------------------------------------------------------------------
   LAYOUT: sidebar + body
   --------------------------------------------------------------------------- */
.ct-page {
  min-height: 100vh;
  display: flex;
  overflow-x: hidden;
}
.ct-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  margin-left: var(--ct-sidebar-width);
  transition: margin-left 0.2s ease;
}
.ct-page.ct-sidebar-collapsed .ct-body {
  margin-left: var(--ct-sidebar-width-collapsed);
}
.ct-main {
  flex: 1;
  padding: var(--ct-space-6) var(--ct-space-4) var(--ct-space-8);
}

/* ---------------------------------------------------------------------------
   SIDEBAR (collapsible, responsive)
   --------------------------------------------------------------------------- */
:root {
  --ct-sidebar-width: 260px;
  --ct-sidebar-width-collapsed: 72px;
}
.ct-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1040;
  width: var(--ct-sidebar-width);
  height: 100vh;
  background: #fff;
  box-shadow: var(--ct-shadow-md);
  display: flex;
  flex-direction: column;
  transition: width 0.2s ease, transform 0.2s ease;
  overflow: hidden;
}
.ct-sidebar-inner {
  display: flex;
  flex-direction: column;
  min-height: 100%;
  padding: var(--ct-space-4) 0;
  width: var(--ct-sidebar-width);
}
.ct-sidebar-header {
  padding: 0 var(--ct-space-4);
  margin-bottom: var(--ct-space-4);
}
.ct-sidebar-brand {
  text-decoration: none;
  color: inherit;
  display: flex;
  align-items: center;
  gap: var(--ct-space-2);
  padding: var(--ct-space-2) 0;
}
.ct-sidebar .ct-brand-icon {
  font-size: 1.5rem;
  color: var(--ct-primary);
  flex-shrink: 0;
}
.ct-sidebar-brand-text {
  white-space: nowrap;
  overflow: hidden;
}
.ct-sidebar-nav {
  padding: 0 var(--ct-space-2);
}
.ct-sidebar-nav .nav-link {
  color: var(--ct-gray-700);
  padding: var(--ct-space-2) var(--ct-space-3);
  border-radius: var(--ct-radius-md);
  margin-bottom: 2px;
}
.ct-sidebar-nav .nav-link:hover {
  background: var(--ct-gray-100);
  color: var(--ct-primary);
}
.ct-sidebar-nav .nav-link.active {
  background: rgba(0, 113, 227, 0.14) !important;
  color: var(--ct-primary) !important;
  font-weight: 600;
}
.ct-sidebar-nav .nav-link.active:hover {
  background: rgba(0, 113, 227, 0.2) !important;
  color: var(--ct-primary) !important;
}
.ct-sidebar-nav .nav-link i {
  font-size: 1.25rem;
  width: 1.5rem;
  flex-shrink: 0;
  text-align: center;
}
.ct-sidebar-text {
  white-space: nowrap;
  overflow: hidden;
}
.ct-sidebar-footer {
  padding: var(--ct-space-4);
  border-top: 1px solid var(--ct-gray-200);
}
.ct-sidebar-user {
  text-decoration: none;
  color: inherit;
  padding: var(--ct-space-2);
  border-radius: var(--ct-radius-md);
}
.ct-sidebar-user:hover {
  background: var(--ct-gray-100);
}
.ct-sidebar-toggle {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 24px;
  height: 48px;
  border: none;
  background: var(--ct-gray-100);
  border-radius: var(--ct-radius-sm) 0 0 var(--ct-radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--ct-gray-600);
  font-size: 0.875rem;
}
.ct-sidebar-toggle:hover {
  background: var(--ct-gray-200);
  color: var(--ct-gray-900);
}
.ct-page.ct-sidebar-collapsed .ct-sidebar {
  width: var(--ct-sidebar-width-collapsed);
}
.ct-page.ct-sidebar-collapsed .ct-sidebar-inner {
  width: var(--ct-sidebar-width-collapsed);
}
.ct-page.ct-sidebar-collapsed .ct-sidebar-brand-text,
.ct-page.ct-sidebar-collapsed .ct-sidebar-text,
.ct-page.ct-sidebar-collapsed .ct-sidebar-user .ct-sidebar-text {
  opacity: 0;
  width: 0;
  overflow: hidden;
  white-space: nowrap;
}
.ct-page.ct-sidebar-collapsed .ct-sidebar-brand {
  justify-content: center;
}
.ct-page.ct-sidebar-collapsed .ct-sidebar-nav .nav-link {
  justify-content: center;
  padding-left: var(--ct-space-3);
}
.ct-page.ct-sidebar-collapsed .ct-sidebar-footer .dropdown-menu {
  margin-left: var(--ct-sidebar-width-collapsed);
}
.ct-sidebar-toggle i {
  transition: transform 0.2s;
}
.ct-page.ct-sidebar-collapsed .ct-sidebar-toggle i {
  transform: rotate(180deg);
}

/* Mobile: sidebar off-canvas */
.ct-sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 1035;
  opacity: 0;
  transition: opacity 0.2s;
}
.ct-sidebar-backdrop.show {
  opacity: 1;
}
@media (max-width: 991.98px) {
  .ct-body {
    margin-left: 0 !important;
  }
  .ct-sidebar {
    transform: translateX(-100%);
    width: var(--ct-sidebar-width);
  }
  .ct-sidebar-inner {
    width: var(--ct-sidebar-width);
  }
  .ct-page.ct-sidebar-mobile-open .ct-sidebar {
    transform: translateX(0);
  }
  .ct-page.ct-sidebar-mobile-open .ct-sidebar-backdrop {
    display: block;
    opacity: 1;
  }
  .ct-sidebar-toggle {
    display: none !important;
  }
  .ct-page.ct-sidebar-collapsed .ct-sidebar-brand-text,
  .ct-page.ct-sidebar-collapsed .ct-sidebar-text {
    opacity: 1;
    width: auto;
  }
}

/* ---------------------------------------------------------------------------
   TOPBAR (slim bar with menu toggle)
   --------------------------------------------------------------------------- */
.ct-topbar {
  background: #fff;
  box-shadow: var(--ct-shadow-sm);
  padding: var(--ct-space-2) var(--ct-space-4);
  display: flex;
  align-items: center;
  gap: var(--ct-space-2);
  min-height: 56px;
}
.ct-topbar-menu-btn,
.ct-sidebar-toggle.d-lg-none {
  border: none;
  background: transparent;
  color: var(--ct-gray-700);
  padding: var(--ct-space-2);
  border-radius: var(--ct-radius-sm);
  cursor: pointer;
}
.ct-topbar-menu-btn:hover,
.ct-sidebar-toggle.d-lg-none:hover {
  background: var(--ct-gray-100);
  color: var(--ct-gray-900);
}
.ct-topbar-spacer {
  flex: 1;
}
.ct-topbar-user-link {
  color: var(--ct-gray-800);
  text-decoration: none;
  padding: var(--ct-space-1) var(--ct-space-2);
  border-radius: var(--ct-radius-sm);
}
.ct-topbar-user-link:hover {
  background: var(--ct-gray-100);
  color: var(--ct-gray-900);
}
.ct-topbar-user-name {
  font-size: var(--ct-font-size-sm);
}
.ct-topbar-brand {
  font-size: var(--ct-font-size-lg);
}

/* ---------------------------------------------------------------------------
   CARDS
   --------------------------------------------------------------------------- */
.ct-card {
  background: #fff;
  border: none;
  border-radius: var(--ct-radius-lg);
  box-shadow: var(--ct-shadow-sm);
  overflow: hidden;
}
.ct-card .card-body {
  padding: var(--ct-space-6);
}

.ct-last-update {
  font-size: var(--ct-font-size-sm);
}
.ct-last-update-pill {
  display: inline-block;
  padding: 0.35rem 0.875rem;
  background: var(--ct-gray-100);
  color: var(--ct-gray-800);
  border: 1px solid var(--ct-gray-300);
  border-radius: 9999px;
  font-weight: 500;
  font-size: var(--ct-font-size-sm);
}

/* ---------------------------------------------------------------------------
   BUTTONS
   --------------------------------------------------------------------------- */
.btn-ct-primary {
  background: var(--ct-primary);
  border: none;
  color: #fff;
  padding: var(--ct-space-2) var(--ct-space-5);
  border-radius: var(--ct-radius-md);
  font-weight: 500;
}
.btn-ct-primary:hover {
  background: var(--ct-primary-hover);
  color: #fff;
}

/* ---------------------------------------------------------------------------
   FORMS
   --------------------------------------------------------------------------- */
.form-control {
  border-radius: var(--ct-radius-md);
  border-color: var(--ct-gray-300);
  padding: var(--ct-space-2) var(--ct-space-3);
}
.form-control:focus {
  border-color: var(--ct-primary);
  box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.15);
}
.form-select {
  border-radius: var(--ct-radius-md);
  border-color: var(--ct-gray-300);
}

/* ---------------------------------------------------------------------------
   TABLES (DataTables) — soft card, sticky header, zebra, pills
   --------------------------------------------------------------------------- */
.ct-table-wrap {
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.06);
  overflow: hidden;
  border: none;
}
.ct-table-wrap .card-body {
  padding: var(--ct-space-4);
  overflow: auto;
}
.ct-table-wrap table.dataTable {
  margin: 0 !important;
  border: none !important;
}
.ct-table-wrap table.dataTable thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f5f5f7 !important;
  color: #6e6e73;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.75rem 1rem;
  border: none !important;
  border-bottom: 1px solid #e8e8ed !important;
  text-align: center;
  white-space: nowrap;
}
/* Keep space and visibility for DataTables sort arrows */
.ct-table-wrap table.dataTable thead th.dt-orderable-asc,
.ct-table-wrap table.dataTable thead th.dt-orderable-desc,
.ct-table-wrap table.dataTable thead th.dt-ordering-asc,
.ct-table-wrap table.dataTable thead th.dt-ordering-desc {
  padding-right: 2rem !important;
}
.ct-table-wrap table.dataTable thead th span.dt-column-order {
  color: #6e6e73;
}
.ct-table-wrap table.dataTable thead th.ct-th-nowrap {
  white-space: nowrap;
  min-width: 5rem;
}
.ct-table-wrap table.dataTable tbody td {
  padding: 0.75rem 1rem;
  border: none !important;
  border-bottom: 1px solid #f0f0f2 !important;
  font-size: 0.875rem;
  vertical-align: middle;
}
.ct-table-wrap table.dataTable tbody tr:nth-child(even) td {
  background: rgba(0, 0, 0, 0.02);
}
.ct-table-wrap table.dataTable tbody tr:hover td {
  background: rgba(0, 0, 0, 0.04);
}
.ct-table-wrap table.dataTable tbody tr:last-child td {
  border-bottom: none !important;
}
/* Address cell: two-line (main bold, town muted) */
.ct-table-wrap .ct-addr-main {
  display: block;
  font-weight: 600;
  color: #1d1d1f;
}
.ct-table-wrap .ct-addr-muted {
  display: block;
  font-size: 0.8125rem;
  color: #6e6e73;
  margin-top: 0.125rem;
}
/* Like: icon button + small count */
.ct-table-wrap .ct-like-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.5rem;
  border: none;
  border-radius: 9999px;
  background: transparent;
  color: #6e6e73;
  font-size: 0.875rem;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}
.ct-table-wrap .ct-like-btn:hover {
  background: rgba(255, 59, 48, 0.08);
  color: #ff3b30;
}
.ct-table-wrap .ct-like-btn .heart-icon {
  font-size: 1.1rem;
}
.ct-table-wrap .ct-like-btn .like-counter {
  font-size: 0.8125rem;
  font-weight: 600;
  color: inherit;
}
.ct-table-wrap .ct-like-btn[data-liked="liked"] {
  color: #ff3b30;
}
.ct-table-wrap.ct-loading {
  opacity: 0.7;
  pointer-events: none;
}
/* Space between "Show" label and length dropdown */
.ct-table-wrap .dt-length select,
#properties-datatable_length select {
  margin-left: 0.5rem;
}

/* Properties DataTable: address left, numeric right, rest center */
#properties-datatable th:nth-child(1),
#properties-datatable td:nth-child(1) { text-align: center; }   /* Likes */
#properties-datatable th:nth-child(2),
#properties-datatable td:nth-child(2) { text-align: center; }   /* Date */
#properties-datatable th:nth-child(3),
#properties-datatable td:nth-child(3) { text-align: left; }      /* Address */
#properties-datatable th:nth-child(4),
#properties-datatable td:nth-child(4) { text-align: right; }     /* Deposit */
#properties-datatable th:nth-child(5),
#properties-datatable td:nth-child(5) { text-align: right; }     /* Fair Market Value */
#properties-datatable th:nth-child(6),
#properties-datatable td:nth-child(6) { text-align: right; }     /* Total debt */
#properties-datatable th:nth-child(7),
#properties-datatable td:nth-child(7) { text-align: right; }     /* Equity */
#properties-datatable th:nth-child(8),
#properties-datatable td:nth-child(8) { text-align: right; }     /* Equity % */
#properties-datatable th:nth-child(9),
#properties-datatable td:nth-child(9) { text-align: center; }   /* Status */
#properties-datatable th:nth-child(10),
#properties-datatable td:nth-child(10) { text-align: center; }   /* Added */

/* ---------------------------------------------------------------------------
   AJAX loader (full-screen overlay)
   --------------------------------------------------------------------------- */
.ct-ajax-loader {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.75);
  backdrop-filter: blur(2px);
}
.ct-ajax-loader[aria-hidden="false"] {
  display: flex;
}
.ct-ajax-loader-spinner {
  width: 48px;
  height: 48px;
  border: 3px solid var(--ct-gray-200);
  border-top-color: var(--ct-primary);
  border-radius: 50%;
  animation: ct-spin 0.8s linear infinite;
}
@keyframes ct-spin {
  to { transform: rotate(360deg); }
}

/* ---------------------------------------------------------------------------
   BADGES
   --------------------------------------------------------------------------- */
.badge-ct {
  font-size: var(--ct-font-size-xs);
  font-weight: 500;
  padding: var(--ct-space-1) var(--ct-space-2);
  border-radius: var(--ct-radius-sm);
}
.badge-ct-success { background: rgba(52, 199, 89, 0.15); color: #248a3d; }
.badge-ct-warning { background: rgba(255, 149, 0, 0.15); color: #c93400; }
.badge-ct-primary { background: rgba(0, 113, 227, 0.12); color: var(--ct-primary); }

/* ---------------------------------------------------------------------------
   ALERTS / TOAST
   --------------------------------------------------------------------------- */
.ct-toast-wrap {
  position: fixed;
  top: var(--ct-space-4);
  left: 50%;
  transform: translateX(-50%);
  z-index: 1100;
  display: flex;
  flex-direction: column;
  gap: var(--ct-space-2);
  pointer-events: none;
}
.ct-toast {
  pointer-events: auto;
  padding: var(--ct-space-3) var(--ct-space-5);
  border-radius: var(--ct-radius-md);
  box-shadow: var(--ct-shadow-lg);
  font-size: var(--ct-font-size-sm);
  background: #fff;
  border: 1px solid var(--ct-gray-200);
  min-width: 280px;
}
.ct-toast-success { border-left: 4px solid var(--ct-success); }
.ct-toast-error { border-left: 4px solid var(--ct-danger); }

/* ---------------------------------------------------------------------------
   STATES: loading, empty, error
   --------------------------------------------------------------------------- */
.ct-state {
  text-align: center;
  padding: var(--ct-space-12) var(--ct-space-6);
  color: var(--ct-gray-500);
}
.ct-state-loading::before {
  content: "";
  display: inline-block;
  width: 32px;
  height: 32px;
  border: 3px solid var(--ct-gray-200);
  border-top-color: var(--ct-primary);
  border-radius: 50%;
  animation: ct-spin 0.8s linear infinite;
  margin-bottom: var(--ct-space-4);
}
@keyframes ct-spin {
  to { transform: rotate(360deg); }
}
.ct-state-empty,
.ct-state-error {
  font-size: var(--ct-font-size-sm);
}

/* ---------------------------------------------------------------------------
   UTILITIES
   --------------------------------------------------------------------------- */
.ct-text-muted { color: var(--ct-gray-500); }
.ct-hot { color: var(--ct-danger); }
.ct-heart-icon { font-size: 1.25rem; vertical-align: middle; }

/* Legacy compatibility (e.g. property show) */
.font-18 { font-size: var(--ct-font-size-lg); }
.font-14 { font-size: var(--ct-font-size-sm); }
