/* ============================================================
   PHYSICIAN ATS — Custom Stylesheet
   Change tokens in :root to retheme the entire app.
   ============================================================ */

/* --- Design Tokens ----------------------------------------- */
:root {
  --ats-primary:            #2563eb;
  --ats-primary-hover:      #1d4ed8;

  --ats-card-radius:        1rem;
  --ats-card-shadow:        0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --ats-card-shadow-hover:  0 4px 12px rgba(0,0,0,.12);

  --ats-sidebar-width:      240px;
  --ats-sidebar-collapsed:  70px;

  --ats-avatar-sm:  40px;
  --ats-avatar-md:  48px;
  --ats-avatar-lg:  64px;

  --ats-section-header-size:   0.75rem;
  --ats-section-header-weight: 700;
}

/* --- App Card ---------------------------------------------- */
.app-card {
  border: none !important;
  border-radius: var(--ats-card-radius) !important;
  box-shadow: var(--ats-card-shadow) !important;
}
.app-card .card-header {
  background: transparent;
  border-bottom: 1px solid rgba(0,0,0,.08);
  padding: .75rem 1.25rem;
}
/* Circular icon in card headers — prevents oval stretching */
.card-header-icon {
  width: 36px;
  height: 36px;
  min-width: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 1rem;
}
.app-card .card-section-title {
  font-size: var(--ats-section-header-size);
  font-weight: var(--ats-section-header-weight);
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--bs-secondary-color);
  margin-bottom: 0;
}
.app-card.kpi-card { overflow: hidden; }

/* Auth pages (login, signup, password reset, public forms) */
.auth-card {
  border-radius: var(--ats-card-radius) !important;
  box-shadow: var(--ats-card-shadow) !important;
}

/* --- Dropzone Card ----------------------------------------- */
.app-dropzone {
  border: 2px dashed #dee2e6 !important;
  border-radius: .5rem !important;
  background: var(--bs-light) !important;
  box-shadow: none !important;
  cursor: pointer;
  transition: border-color .2s ease, background .2s ease;
}
.app-dropzone:hover,
.app-dropzone.dragover {
  border-color: var(--ats-primary) !important;
  background: #e0e7ff !important;
}

/* --- Avatar System ----------------------------------------- */
.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-weight: 700;
  flex-shrink: 0;
  font-size: .875rem;
  line-height: 1;
}
img.avatar { object-fit: cover; }
.avatar-xs { width: 32px; height: 32px; font-size: 0.75rem; }
.avatar-sm { width: var(--ats-avatar-sm); height: var(--ats-avatar-sm); }
.avatar-md { width: var(--ats-avatar-md); height: var(--ats-avatar-md); }
.avatar-lg { width: var(--ats-avatar-lg); height: var(--ats-avatar-lg); font-size: 1.5rem; }

/* --- Page Header ------------------------------------------- */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1.5rem;
  gap: 1rem;
}
.page-header-title {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 0;
  line-height: 1.2;
}
.page-header-subtitle {
  font-size: .875rem;
  color: var(--bs-secondary-color);
  margin: .125rem 0 0;
}

/* --- Form Section Header ----------------------------------- */
.form-section-header {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: var(--ats-section-header-size);
  font-weight: var(--ats-section-header-weight);
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--bs-secondary-color);
  margin-top: 1.75rem;
  margin-bottom: .75rem;
}
.form-section-header i { opacity: .7; }

/* --- Empty State ------------------------------------------- */
.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--bs-secondary-color);
}
.empty-state-icon {
  font-size: 2.5rem;
  opacity: .2;
  display: block;
  margin-bottom: .75rem;
}
.empty-state-title {
  font-weight: 600;
  margin-bottom: .25rem;
}
.empty-state-text {
  font-size: .9375rem;
  margin-bottom: 0;
}

/* --- Form Action Bar (sticky bottom) ----------------------- */
/* Styled like .app-card — soft shadow, rounded corners — so it visually
   belongs with the form cards above. Width inherits from its container. */
.form-action-bar {
  position: sticky;
  bottom: 1rem;
  background: #fff;
  border: none;
  border-radius: var(--ats-card-radius);
  box-shadow: var(--ats-card-shadow);
  padding: 1rem 1.5rem;
  margin-top: 1.5rem;
  z-index: 10;
}

/* --- Dashboard Layout -------------------------------------- */
.dashboard-layout {
  min-height: 100vh;
}

/* --- Sidebar ----------------------------------------------- */
.sidebar-wrapper {
  width: var(--ats-sidebar-width);
}
@media (min-width: 768px) {
  .sidebar-wrapper {
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
  }
}

/* Nav links — modern non-collapsible style */
.sidebar-nav-link {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.4375rem 0.75rem;
  border-radius: 0.5rem;
  color: #374151;
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  transition: background 0.1s, color 0.1s;
}
.sidebar-nav-link i {
  font-size: 1rem;
  width: 1.25rem;
  text-align: center;
  flex-shrink: 0;
  color: #9ca3af;
  transition: color 0.1s;
}
.sidebar-nav-link:hover {
  background: #f3f4f6;
  color: #111827;
}
.sidebar-nav-link:hover i { color: #6b7280; }
.sidebar-nav-link.active {
  background: #eff6ff;
  color: var(--ats-primary);
  font-weight: 600;
}
.sidebar-nav-link.active i { color: var(--ats-primary); }

.sidebar-nav-section-label {
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #9ca3af;
  padding: 0 0.75rem;
  margin-top: 1.25rem;
  margin-bottom: 0.25rem;
}

/* Mobile: sidebar slides in from left */
@media (max-width: 767.98px) {
  #sidebar-wrapper {
    position: fixed;
    top: 0; left: 0;
    z-index: 1045;
    transform: translateX(-100%);
    transition: transform .3s ease;
    height: 100vh;
    overflow-y: auto;
  }
  #sidebar-wrapper.mobile-open { transform: translateX(0); }
}
@media (min-width: 768px) {
  #sidebar-wrapper { transform: none !important; }
}

/* --- Third-party Widget Overrides -------------------------- */

/* intl-tel-input */
.iti { width: 100%; }
.iti ~ .invalid-feedback { display: block; }

/* Flatpickr */
.flatpickr-calendar {
  border-radius: 12px !important;
  box-shadow: 0 10px 40px rgba(0,0,0,.15) !important;
  border: none !important;
}
.flatpickr-months { border-radius: 12px 12px 0 0; }
.flatpickr-day.selected,
.flatpickr-day.selected:hover {
  background: var(--ats-primary) !important;
  border-color: var(--ats-primary) !important;
}
.flatpickr-day:hover {
  background: #e0e7ff !important;
  border-color: #e0e7ff !important;
}
.flatpickr-day.today { border-color: var(--ats-primary) !important; }
.flatpickr-input { cursor: pointer !important; }
.flatpickr-input:read-only { background-color: #fff !important; }

/* Tom Select */
.ts-control { border-radius: .375rem !important; }

/* Large toggle switch */
.form-switch.form-switch-lg { padding-left: 3rem; }
.form-switch.form-switch-lg .form-check-input {
  width: 3rem;
  height: 1.5rem;
  margin-top: .1rem;
  margin-left: -3rem;
  cursor: pointer;
  border-radius: 1rem;
  transition: all .2s ease;
}
.form-switch.form-switch-lg .form-check-input:checked {
  background-color: var(--ats-primary);
  border-color: var(--ats-primary);
}
.form-switch.form-switch-lg .form-check-input:focus {
  box-shadow: 0 0 0 .25rem rgba(37,99,235,.25);
  border-color: var(--ats-primary);
}

/* --- Badge Size Utilities ---------------------------------- */
.badge-xs { font-size: 0.65rem; }
.badge-sm { font-size: 0.75rem; }

/* --- Avatar XL (profile picture preview) ------------------ */
.avatar-xl { width: 150px; height: 150px; font-size: 2.5rem; }
.avatar-xl.avatar-bordered { border: 4px solid #e9ecef; }

/* --- Scrollable List --------------------------------------- */
.scrollable-list    { max-height: 400px; overflow-y: auto; }
.scrollable-list-sm { max-height: 300px; overflow-y: auto; }

/* --- Utilities --------------------------------------------- */
.min-w-0 { min-width: 0; }
.text-truncate-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hover-underline:hover { text-decoration: underline !important; }
.hover-bg-light:hover  { background-color: #f8f9fa; }
.transition            { transition: all .2s ease-in-out; }
.hover-lift:hover {
  transform: translateY(-3px);
  box-shadow: var(--ats-card-shadow-hover) !important;
}

/* Navbar logout button (inline form button) */
.nav-logout-btn {
  display: inline;
  border: none;
  background: none;
  padding: 0;
}

/* Pulse animation for new-count badges */
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: .6; }
}
.pulse-badge { animation: pulse 2s ease-in-out infinite; }

/* Contenteditable placeholder (notes editor) */
[contenteditable]:empty:before {
  content: attr(placeholder);
  color: var(--bs-secondary-color);
  pointer-events: none;
  display: block;
}

/* Responsive width utility */
@media (min-width: 768px) {
  .w-md-auto { width: auto !important; }
}

/* Better mobile spacing for attention cards */
@media (max-width: 575.98px) {
  .attention-card-item .badge { font-size: .7rem; }
}

/* Communications — email dashboard table */
.email-table-row { cursor: pointer; }
.email-meta-small { font-size: 0.75rem; }
.email-subject-cell { max-width: 300px; }

/* Communications — email preview iframe */
.email-preview-wrapper {
  border-radius: 0 0 0.75rem 0.75rem;
  overflow: hidden;
}
.email-preview-iframe {
  width: 100%;
  border: none;
  display: block;
  min-height: 500px;
}

/* --- Ontario Region Map ---------------------------------------- */
.ontario-map-wrapper {
  width: 100%;
}

/* --- Quill rich-text editor ------------------------------------ */
/* Applied to editor elements via .quill-editor-host (new forms) or by ID
   on older templates (job_form, communications). Both get the same look. */
.quill-editor-host,
#quill-description,
#quill-editor { min-height: 140px; display: block; }
.quill-editor-host .ql-editor,
#quill-description .ql-editor,
#quill-editor .ql-editor { min-height: 120px; font-size: 0.95rem; }
.ql-toolbar.ql-snow { border-radius: 0.5rem 0.5rem 0 0; }
.ql-container.ql-snow { border-radius: 0 0 0.5rem 0.5rem; position: relative; }

/* --- HTMX Loading Indicator ----- */
.htmx-indicator {
  display: none;
}
.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
  display: inline-block;
}

#global-htmx-indicator {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  z-index: 9999;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
}
#global-htmx-indicator.htmx-request {
  opacity: 1;
}
#global-htmx-indicator .bar {
  height: 100%;
  width: 30%;
  background: var(--ats-primary);
  animation: htmx-progress 1s ease-in-out infinite;
}
@keyframes htmx-progress {
  0%   { margin-left: -30%; }
  100% { margin-left: 100%; }
}
