/* ==========================================================================
   finCRM — Custom CSS (supplements TailwindCSS)
   ========================================================================== */

/* ---- Dark scrollbar ---------------------------------------------------- */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: #111827; /* gray-900 */
}

::-webkit-scrollbar-thumb {
  background: #374151; /* gray-700 */
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: #4b5563; /* gray-600 */
}

/* Firefox */
* {
  scrollbar-width: thin;
  scrollbar-color: #374151 #111827;
}

/* Sidebar-specific scrollbar */
.sidebar-scroll::-webkit-scrollbar {
  width: 4px;
}

.sidebar-scroll::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar-scroll::-webkit-scrollbar-thumb {
  background: #1f2937; /* gray-800 */
  border-radius: 2px;
}

/* ---- Table improvements ------------------------------------------------ */
table th {
  position: relative;
}

/* Subtle column separator */
table th + th::before {
  content: '';
  position: absolute;
  left: 0;
  top: 25%;
  height: 50%;
  width: 1px;
  background: #1f2937; /* gray-800 */
}

/* Monospace small utility */
.font-mono-sm {
  font-family: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Monaco, 'Cascadia Code', 'Consolas', monospace;
  font-size: 0.8125rem;
}

/* ---- Transition utilities ---------------------------------------------- */
.fade-in {
  animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* HTMX loading indicator */
.htmx-indicator {
  display: none;
}

.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
  display: inline-flex;
}

/* Subtle skeleton pulse for loading states */
.skeleton {
  background: linear-gradient(90deg, #1f2937 25%, #374151 50%, #1f2937 75%);
  background-size: 200% 100%;
  animation: skeleton-pulse 1.5s ease-in-out infinite;
  border-radius: 4px;
}

@keyframes skeleton-pulse {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ---- Print styles ------------------------------------------------------ */
@media print {
  /* Hide navigation */
  aside,
  header,
  .no-print {
    display: none !important;
  }

  /* Reset main content positioning */
  main {
    margin-left: 0 !important;
    padding-top: 0 !important;
  }

  /* Light background for printing */
  body {
    background: white !important;
    color: black !important;
  }

  table {
    border-collapse: collapse;
  }

  table th,
  table td {
    border: 1px solid #ccc;
    color: black !important;
    background: white !important;
  }

  table th {
    background: #f0f0f0 !important;
  }

  /* Remove shadows and borders */
  .shadow,
  .shadow-lg,
  .shadow-xl,
  .shadow-2xl {
    box-shadow: none !important;
  }
}

/* ---- Mobile responsive ------------------------------------------------- */
@media (max-width: 640px) {
  /* Compact table cells */
  table td, table th {
    padding-left: 0.5rem !important;
    padding-right: 0.5rem !important;
    font-size: 0.75rem;
  }

  /* Ensure horizontal scroll on tables */
  .overflow-x-auto {
    -webkit-overflow-scrolling: touch;
  }

  /* Compact cards */
  .grid {
    gap: 0.75rem;
  }

  /* Full-width modals */
  .max-w-md, .max-w-lg, .max-w-2xl {
    max-width: calc(100vw - 2rem) !important;
  }

  /* Compact stat cards */
  .stat-card, [class*="stat_card"] {
    padding: 0.75rem !important;
  }
}

/* Touch-friendly tap targets */
@media (pointer: coarse) {
  button, a, [role="button"], select, input[type="checkbox"] {
    min-height: 36px;
    min-width: 36px;
  }

  /* Bigger checkboxes on touch */
  input[type="checkbox"] {
    width: 1.125rem !important;
    height: 1.125rem !important;
  }
}

/* ---- Misc -------------------------------------------------------------- */

/* Selection color */
::selection {
  background: rgba(99, 102, 241, 0.3); /* indigo-500/30 */
}

/* Disable outline on non-keyboard focus */
:focus:not(:focus-visible) {
  outline: none;
}

/* Alpine.js cloak */
[x-cloak] {
  display: none !important;
}
