/* ============================================
   KLINIKE MEDICAL - Custom Styles
   ============================================ */

/* ---- CSS Variables ---- */
:root {
  --nexus-primary: #0d6efd;
  --nexus-primary-dark: #0a58ca;
  --nexus-success: #198754;
  --nexus-danger: #dc3545;
  --nexus-warning: #ffc107;
  --nexus-dark: #212529;
  --nexus-light: #f8f9fa;
  --nexus-card-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
  --nexus-card-hover-shadow: 0 4px 20px rgba(13, 110, 253, 0.15);
  --nexus-border-radius: 0.5rem;
  --nexus-transition: all 0.2s ease;
}

/* ============================================
   NAVBAR
   ============================================ */

.navbar {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

.navbar-brand {
  font-size: 1.2rem;
  letter-spacing: -0.01em;
}

.navbar .nav-link {
  font-size: 0.9rem;
  padding-left: 0.75rem;
  padding-right: 0.75rem;
  transition: var(--nexus-transition);
}

.navbar .nav-link:hover {
  opacity: 0.85;
}

/* Avatar circles */
.avatar-circle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  font-weight: 700;
  flex-shrink: 0;
  user-select: none;
}

.avatar-circle-xs {
  width: 28px;
  height: 28px;
  font-size: 0.75rem;
}

.avatar-circle-sm {
  width: 32px;
  height: 32px;
  font-size: 0.85rem;
}

.avatar-circle-md {
  width: 44px;
  height: 44px;
  font-size: 1.1rem;
}

.avatar-circle-lg {
  width: 60px;
  height: 60px;
  font-size: 1.5rem;
}

.avatar-circle-xl {
  width: 80px;
  height: 80px;
  font-size: 2rem;
}

/* ============================================
   CASE CARDS
   ============================================ */

.case-card {
  border-radius: var(--nexus-border-radius);
  box-shadow: var(--nexus-card-shadow);
  transition: var(--nexus-transition);
  position: relative;
  overflow: hidden;
}

.case-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--nexus-card-hover-shadow);
}

.case-card .card-footer {
  background-color: transparent;
}

.case-title-link:hover {
  color: var(--nexus-primary) !important;
}

/* ============================================
   IMAGE SLIDER
   ============================================ */

.slider-main-image {
  width: 100%;
  max-height: 520px;
  object-fit: contain;
  background-color: #1a1a1a;
  border-radius: var(--nexus-border-radius);
}

.slider-thumbnails {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding-bottom: 0.5rem;
  scrollbar-width: thin;
  scrollbar-color: var(--nexus-primary) #e9ecef;
  -webkit-overflow-scrolling: touch;
}

.slider-thumbnails::-webkit-scrollbar {
  height: 4px;
}

.slider-thumbnails::-webkit-scrollbar-track {
  background: #e9ecef;
  border-radius: 2px;
}

.slider-thumbnails::-webkit-scrollbar-thumb {
  background-color: var(--nexus-primary);
  border-radius: 2px;
}

.slider-thumbnail {
  flex-shrink: 0;
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 0.375rem;
  border: 2px solid transparent;
  cursor: pointer;
  transition: var(--nexus-transition);
  opacity: 0.65;
}

.slider-thumbnail:hover,
.slider-thumbnail.active {
  opacity: 1;
  border-color: var(--nexus-primary);
}

.slider-nav-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 10;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  cursor: pointer;
  transition: background 0.15s ease;
}

.slider-nav-btn:hover {
  background: rgba(0, 0, 0, 0.8);
}

.slider-nav-prev {
  left: 0.75rem;
}

.slider-nav-next {
  right: 0.75rem;
}

/* ============================================
   THUMBNAILS (general)
   ============================================ */

.img-thumbnail-card {
  border-radius: var(--nexus-border-radius);
  overflow: hidden;
}

.img-thumbnail-card img {
  width: 100%;
  height: 120px;
  object-fit: cover;
  transition: transform 0.2s ease;
}

.img-thumbnail-card:hover img {
  transform: scale(1.04);
}

/* ============================================
   COMMENTS
   ============================================ */

.comment-item {
  border-left: 3px solid #e9ecef;
  padding-left: 1rem;
  transition: border-color 0.2s ease;
}

.comment-item:hover {
  border-left-color: var(--nexus-primary);
}

.comment-item .comment-author-avatar {
  width: 36px;
  height: 36px;
  font-size: 0.9rem;
}

.comment-text {
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.6;
}

.thumbnail-item {
  width: 72px;
  height: 72px;
  background: #f8f9fa;
  border: 1px solid #dee2e6 !important;
}

.thumbnail-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.main-carousel-img-wrap {
  min-height: 320px;
}

.carousel-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 11;
  border: 0;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.95);
}

.carousel-btn-prev {
  left: 12px;
}

.carousel-btn-next {
  right: 12px;
}

[x-cloak] {
  display: none !important;
}

/* ============================================
   PROFILE HEADER
   ============================================ */

.profile-header {
  position: relative;
}

.profile-header::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, rgba(255,255,255,0.3) 0%, rgba(255,255,255,0.1) 100%);
}

/* ============================================
   FOLLOW BUTTON
   ============================================ */

.follow-btn {
  transition: var(--nexus-transition);
  min-width: 120px;
}

.follow-btn:hover {
  transform: scale(1.04);
}

/* ============================================
   ANONYMIZATION WARNING
   ============================================ */

.alert-danger.border-2 {
  background-color: #fff5f5;
}

.alert-danger.border-2 ul li {
  margin-bottom: 0.25rem;
}

#appConfirmModal .modal-content {
  border-radius: 1rem;
}

#appConfirmModal .modal-footer .btn {
  min-width: 120px;
}

/* ============================================
   TAGS
   ============================================ */

.tag-badge {
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  transition: var(--nexus-transition);
}

.tag-badge:hover {
  background-color: #e2e6ea !important;
}

/* ============================================
   MEDICAL CODE TABLES / SEARCH
   ============================================ */

.code-search-results {
  max-height: 280px;
  overflow-y: auto;
  z-index: 1050;
  border-color: #dee2e6 !important;
}

.code-result-item {
  border-bottom: 1px solid #f8f9fa !important;
  transition: background-color 0.1s ease;
  cursor: pointer;
}

.code-result-item:last-child {
  border-bottom: none !important;
}

.code-result-item:hover {
  background-color: #f0f4ff !important;
}

/* ============================================
   FILE DROP ZONE
   ============================================ */

.upload-dropzone {
  border-style: dashed !important;
  border-width: 2px !important;
  transition: var(--nexus-transition);
  background-color: #fafbfc;
  cursor: pointer;
}

.upload-dropzone:hover,
.upload-dropzone.dragover {
  background-color: #eef4ff;
  border-color: var(--nexus-primary) !important;
}

.upload-dropzone:focus {
  outline: 2px solid var(--nexus-primary);
  outline-offset: 2px;
}

/* ============================================
   FLASH MESSAGES
   ============================================ */

.flash-messages-container {
  position: relative;
  z-index: 1040;
}

.flash-message {
  border-left-width: 4px;
  border-radius: var(--nexus-border-radius);
  box-shadow: var(--nexus-card-shadow);
}

.flash-message.alert-success {
  border-left-color: var(--nexus-success);
}

.flash-message.alert-danger {
  border-left-color: var(--nexus-danger);
}

.flash-message.alert-warning {
  border-left-color: var(--nexus-warning);
}

.flash-message.alert-info {
  border-left-color: var(--nexus-primary);
}

/* ============================================
   ADMIN
   ============================================ */

.admin-stat-card {
  border-radius: var(--nexus-border-radius);
  transition: var(--nexus-transition);
}

.admin-stat-card:hover {
  box-shadow: var(--nexus-card-hover-shadow);
  transform: translateY(-1px);
}

.table th {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
}

.table td {
  vertical-align: middle;
}

/* ============================================
   FOOTER
   ============================================ */

.footer {
  font-size: 0.875rem;
}

.footer a:hover {
  color: #fff !important;
  transition: color 0.15s ease;
}

/* ============================================
   HTMX LOADING INDICATOR
   ============================================ */

.htmx-indicator {
  display: none;
}

.htmx-request .htmx-indicator {
  display: inline-block;
}

.htmx-request.htmx-indicator {
  display: inline-block;
}

/* Global loading bar at top of page */
#htmx-loading-bar {
  position: fixed;
  top: 0;
  left: 0;
  width: 0%;
  height: 3px;
  background: linear-gradient(90deg, var(--nexus-primary), #6ea8fe);
  z-index: 9999;
  transition: width 0.3s ease;
}

body.htmx-request #htmx-loading-bar {
  width: 70%;
}

/* ============================================
   FEED - FOLLOWED INDICATOR
   ============================================ */

.followed-indicator {
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: linear-gradient(180deg, var(--nexus-primary) 0%, #6ea8fe 100%);
  border-radius: var(--nexus-border-radius) 0 0 var(--nexus-border-radius);
}

/* ============================================
   PAGINATION
   ============================================ */

.pagination .page-link {
  border-radius: var(--nexus-border-radius);
  margin: 0 2px;
  font-size: 0.9rem;
  transition: var(--nexus-transition);
}

.pagination .page-link:hover {
  background-color: #e7f0ff;
  border-color: var(--nexus-primary);
  color: var(--nexus-primary);
}

.pagination .page-item.active .page-link {
  background-color: var(--nexus-primary);
  border-color: var(--nexus-primary);
}

/* ============================================
   EMPTY STATES
   ============================================ */

.empty-state {
  min-height: 280px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.empty-state i {
  opacity: 0.4;
}

/* ============================================
   MISC UTILITIES
   ============================================ */

.cursor-pointer {
  cursor: pointer;
}

.object-fit-cover {
  object-fit: cover;
}

.min-width-0 {
  min-width: 0;
}

.hover-shadow {
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}

.hover-shadow:hover {
  box-shadow: var(--nexus-card-hover-shadow);
  transform: translateY(-1px);
}

/* ============================================
   MOBILE OPTIMIZATIONS (media queries)
   ============================================ */

/* xs: < 576px */
@media (max-width: 575.98px) {
  .case-card {
    margin-bottom: 0.5rem;
  }

  .slider-main-image {
    max-height: 260px;
  }

  .slider-thumbnail {
    width: 56px;
    height: 56px;
  }

  .profile-header .h2 {
    font-size: 1.4rem;
  }

  .upload-dropzone {
    padding: 1.5rem 1rem !important;
  }

  .code-search-results {
    max-height: 200px;
  }

  .table-responsive {
    font-size: 0.85rem;
  }

  h1.display-1 {
    font-size: 5rem !important;
  }

  .flash-messages-container .container {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
  }

  .pagination .page-link {
    padding: 0.3rem 0.6rem;
    font-size: 0.8rem;
  }
}

/* sm: 576px – 767px */
@media (min-width: 576px) and (max-width: 767.98px) {
  .slider-main-image {
    max-height: 360px;
  }
}

/* md: 768px – 991px */
@media (min-width: 768px) and (max-width: 991.98px) {
  .slider-main-image {
    max-height: 440px;
  }
}

/* Large screens: card grid adjustments */
@media (min-width: 992px) {
  .case-card:hover {
    transform: translateY(-3px);
  }
}
