/* SIConfirm modal: top of screen, smaller, larger text */
.modal.si-confirm-top .modal-dialog {
  margin: 2rem auto 0 auto !important;
  top: 0;
  transform: none !important;
  max-width: 350px;
}
.modal.si-confirm-top .modal-content {
  font-size: 1.08rem;
  padding: 0.75rem 1.25rem;
}
.modal.si-confirm-top .modal-header,
.modal.si-confirm-top .modal-footer {
  padding: 0.5rem 1rem;
}
.modal.si-confirm-top .modal-title {
  font-size: 1.15rem;
}
.modal.si-confirm-top .modal-body p {
  font-size: 1.08rem;
  margin-bottom: 0.5rem;
}
/* Animal table selected row highlight (side line) */
.table .selected-row {
  border-left: 4px solid var(--si-primary) !important;
  box-shadow: none;
}
/* Highlight for selected table row */
.table .clickable-row.selected, .table tr.selected {
  background-color: #d4edda !important;
  transition: background 0.2s;
  border-left: 4px solid var(--si-primary);
}
/* Force scroll area for sidepanel on mobile and always show scrollbar if needed */
.sidepanel-scroll-area {
  height: 100vh;
  max-height: 100dvh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

@media (max-width: 991.98px) {
  .sidepanel-scroll-area {
    height: 100dvh !important;
    max-height: 100dvh !important;
    min-height: 0 !important;
    overflow-y: auto !important;
    overscroll-behavior: contain !important;
    background: white;
    padding-top: 56px !important;
    padding-bottom: 80px !important;
    padding-left: 16px !important;
    padding-right: 8px !important;
    box-sizing: border-box;
  }
}
/**
 * ScanInsights Home Office Theme
 * Brand colours and styling for commercial-ready UI
 * 
 */

/* ============================================
   CSS VARIABLES - BRAND COLOURS
   ============================================ */
:root {
  /* Primary Brand Colours */
  --si-primary: #1B5E3B;
  --si-primary-hover: #2E7D4A;
  --si-primary-light: #4CAF50;
  
  /* Secondary Colours */
  --si-secondary: #6c757d;
  --si-secondary-hover: #5a6268;
  
  /* Status Colours */
  --si-success: #4CAF50;
  --si-warning: #ffc107;
  --si-danger: #dc3545;
  --si-info: #17a2b8;
  
  /* Background Colours */
  --si-bg-light: #F8F9FA;
  --si-bg-white: #ffffff;
  --si-bg-dark: #1B5E3B;
  
  /* Text Colours */
  --si-text-primary: #212529;
  --si-text-secondary: #6c757d;
  --si-text-light: #ffffff;
  
  /* Table Row Colours (existing + documented) */
  --si-row-registered: #d4edda;      /* Green - Registered Animal */
  --si-row-unregistered: #fcd4dc;    /* Red - Unregistered Animal */
  /* Borders */
  --si-border-color: #dee2e6;
  --si-border-radius: 0.375rem;
  
  /* Shadows */
  --si-shadow-sm: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
  --si-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
}

/* ============================================
   GLOBAL STYLES
   ============================================ */
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background-color: var(--si-bg-light);
  color: var(--si-text-primary);
}

/* ============================================
   NAVBAR BRANDING
   ============================================ */
.navbar {
  background-color: var(--si-primary) !important;
  box-shadow: var(--si-shadow-sm);
}

.navbar-brand {
  color: var(--si-text-light) !important;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.navbar-brand:hover {
  color: var(--si-text-light) !important;
  opacity: 0.9;
}

.navbar-brand img {
  height: 32px;
  width: auto;
  background: transparent;
}

/* Login page logo */
.login-logo img {
  background: transparent;
  max-height: 80px;
  width: auto;
}

.navbar .nav-link {
  color: rgba(255, 255, 255, 0.85) !important;
}

.navbar .nav-link:hover,
.navbar .nav-link.active {
  color: var(--si-text-light) !important;
}

.navbar-toggler {
  border-color: rgba(255, 255, 255, 0.5);
}

.navbar-toggler-icon {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba%28255, 255, 255, 0.85%29' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");
}

/* ============================================
   BUTTONS - BRAND COLOURS
   ============================================ */
.btn-primary,
.btn-outline-success {
  background-color: var(--si-primary);
  border-color: var(--si-primary);
  color: var(--si-text-light);
}

.btn-primary:hover,
.btn-outline-success:hover {
  background-color: var(--si-primary-hover);
  border-color: var(--si-primary-hover);
  color: var(--si-text-light);
}

.btn-primary:focus,
.btn-outline-success:focus {
  background-color: var(--si-primary-hover);
  border-color: var(--si-primary-hover);
  box-shadow: 0 0 0 0.2rem rgba(27, 94, 59, 0.5);
}

.btn-outline-primary {
  color: var(--si-primary);
  border-color: var(--si-primary);
}

.btn-outline-primary:hover {
  background-color: var(--si-primary);
  border-color: var(--si-primary);
  color: var(--si-text-light);
}

/* ============================================
   TABLES
   ============================================ */
.table-hover tbody tr:hover td {
  background-color: rgba(27, 94, 59, 0.1) !important;
}

/* Row status colours */
.table-success,
tr.table-success td {
  background-color: var(--si-row-registered) !important;
}

.table-danger,
tr.table-danger td {
  background-color: var(--si-row-unregistered) !important;
}

/* ============================================
   COLOUR LEGEND (for tables)
   ============================================ */
.colour-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  padding: 0.5rem;
  background-color: var(--si-bg-white);
  border-radius: var(--si-border-radius);
  border: 1px solid var(--si-border-color);
}

.colour-legend-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.colour-legend-box {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  border: 1px solid rgba(0, 0, 0, 0.1);
}

.colour-legend-box.registered {
  background-color: var(--si-row-registered);
}

.colour-legend-box.unregistered {
  background-color: var(--si-row-unregistered);
}

.colour-legend-box.duplicate-in-herd {
  background-color: #d1ecf1; /* Light blue/cyan for duplicate in herd */
}

.colour-legend-box.duplicate-not-in-herd {
  background-color: #f8d7da; /* Light red for duplicate not in herd */
}

.colour-legend-text {
  font-size: 0.875rem;
  color: var(--si-text-secondary);
}

/* ============================================
   SIDE PANEL STYLES
   ============================================ */
.sticky-sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  background-color: var(--si-bg-white);
  padding: 1rem;
  border-left: 1px solid var(--si-border-color);
}

/* ============================================
   MOBILE RESPONSIVENESS
   ============================================ */

/* Mobile offcanvas for side panels */
@media (max-width: 991.98px) {
  /* CRITICAL: Sidebar must be completely independent of parent container */
  .sticky-sidebar {
     position: fixed !important;
     top: 0 !important;
     right: -100% !important;
     left: auto !important;
     width: 92% !important;
     min-width: 340px !important;
     max-width: 500px !important;
     height: 100vh !important;
     height: 100dvh !important; /* Dynamic viewport height for iOS */
     max-height: 100dvh !important;
     z-index: 1050 !important;
     transition: right 0.3s ease-in-out !important;
     box-shadow: -2px 0 10px rgba(0, 0, 0, 0.1) !important;
     background-color: white !important;
     overflow-y: auto !important;
     overflow-x: hidden !important;
     -webkit-overflow-scrolling: touch !important; /* iOS momentum scrolling */
     overscroll-behavior: contain !important; /* Prevent scroll chaining */
     padding: 1rem !important;
     padding-bottom: 100px !important; /* Extra space at bottom */
     /* Override any parent flex/width settings */
     flex: none !important;
     margin: 0 !important;
  }
  
  .sticky-sidebar.show {
    right: 0 !important;
  }
  
  .sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1040;
    display: none;
  }
  
  .sidebar-overlay.show {
    display: block !important;
  }

  /* Prevent body scroll when sidebar is open on mobile */
  body.sidebar-open {
    overflow: hidden !important;
  }
  
  /* Mobile toggle button */
  .sidebar-toggle {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background-color: var(--si-primary);
    color: var(--si-text-light);
    border: none;
    box-shadow: var(--si-shadow);
    z-index: 1030;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
  }
  
  .sidebar-toggle:hover {
    background-color: var(--si-primary-hover);
  }
  
  /* Close button for mobile sidebar */
  .sidebar-close {
    position: absolute;
    top: 10px;
    right: 10px;
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--si-text-secondary);
    cursor: pointer;
  }
  
  /* Make main content full width on mobile */
  .col-lg-9,
  .col-lg-8,
  .col-lg-6 {
    width: 100% !important;
    max-width: 100% !important;
    flex: 0 0 100% !important;
  }
  
  /* Hide desktop sidebar columns on mobile - set to zero width instead of display:none */
  /* This keeps the sticky-sidebar accessible since it's position:fixed */
  .col-lg-3,
  .col-lg-4 {
    width: 0 !important;
    padding: 0 !important;
    overflow: visible !important;
    flex: 0 !important;
  }
  
  .sidenav:not(.sticky-sidebar) {
    display: none;
  }
  
  /* Ensure sticky-sidebar is always visible on mobile (it's position:fixed) */
  .sticky-sidebar {
    display: block !important;
  }
}

/* Tablet adjustments */
@media (min-width: 768px) and (max-width: 991.98px) {
  .sticky-sidebar {
    width: 50%;
    max-width: 450px;
  }
}

/* Desktop - hide mobile toggle */
@media (min-width: 992px) {
  .sidebar-toggle {
    display: none !important;
  }
  
  .sidebar-overlay {
    display: none !important;
  }
  
  .sidebar-close {
    display: none !important;
  }
}

/* ============================================
   RESPONSIVE TABLES
   ============================================ */
.table-responsive-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 1rem;
}

@media (max-width: 767.98px) {
  .table {
    font-size: 0.875rem;
  }
  
  .table th,
  .table td {
    padding: 0.5rem;
    white-space: nowrap;
  }
}

/* ============================================
   RESPONSIVE VIDEO PLAYER
   Optimized for ultrasound scan videos
   Videos are typically 1024x256 (4:1) but may be rotated
   The player auto-adjusts to video's intrinsic dimensions
   ============================================ */

/* Video wrapper - provides consistent container */
.video-player-wrapper {
  width: 100%;
  background-color: #000;
  border-radius: var(--si-border-radius);
  overflow: hidden;
  /* Let the video determine the height naturally */
}

/* Main video player styles */
.scan-video-player {
  display: block;
  width: 100%;
  height: auto; /* CRITICAL: Let video determine its own height */
  max-width: 100%;
  background-color: #000;
  border-radius: var(--si-border-radius);
  object-fit: contain; /* Maintain aspect ratio, no cropping */
}

/* Desktop: Video fits naturally within sidebar */
@media (min-width: 992px) {
  .scan-video-player {
    /* No max-height restriction - video shows at natural aspect ratio */
    width: 100%;
    height: auto;
  }
  
  .video-player-wrapper {
    max-width: 100%;
  }
}

/* Tablet (iPad): Optimized for medium screens */
@media (min-width: 768px) and (max-width: 991.98px) {
  .scan-video-player {
    width: 100%;
    height: auto;
  }
  
  .video-player-wrapper {
    margin: 0 auto;
  }
}

/* Mobile: Full width, auto height */
@media (max-width: 767.98px) {
  .scan-video-player {
    width: 100%;
    height: auto;
    border-radius: var(--si-border-radius-sm);
  }
  
  .video-player-wrapper {
    border-radius: var(--si-border-radius-sm);
  }
}

/* Legacy video-container support (for backwards compatibility) */
.video-container {
  position: relative;
  width: 100%;
  background-color: #000;
  border-radius: var(--si-border-radius);
  overflow: hidden;
}

.video-container video,
.video-container iframe {
  width: 100%;
  height: auto;
  object-fit: contain;
}

/* ============================================
   LOADING SPINNER
   ============================================ */
.si-loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(255, 255, 255, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.si-loading-overlay.show {
  opacity: 1;
  visibility: visible;
}

.si-spinner {
  width: 50px;
  height: 50px;
  border: 4px solid var(--si-border-color);
  border-top-color: var(--si-primary);
  border-radius: 50%;
  animation: si-spin 0.8s linear infinite;
}

@keyframes si-spin {
  to {
    transform: rotate(360deg);
  }
}

/* Inline loading spinner for buttons */
.btn-loading {
  position: relative;
  pointer-events: none;
  color: transparent !important;
}

.btn-loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 1rem;
  height: 1rem;
  margin: -0.5rem 0 0 -0.5rem;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: si-spin 0.6s linear infinite;
}

.btn-loading::after {
  border-color: var(--si-text-light);
  border-right-color: transparent;
}

/* ============================================
   TOAST NOTIFICATIONS
   ============================================ */
.si-toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 350px;
}

.si-toast {
  display: flex;
  align-items: flex-start;
  padding: 1rem;
  border-radius: var(--si-border-radius);
  box-shadow: var(--si-shadow);
  background-color: var(--si-bg-white);
  border-left: 4px solid var(--si-primary);
  animation: si-toast-in 0.3s ease forwards;
}

.si-toast.hiding {
  animation: si-toast-out 0.3s ease forwards;
}

@keyframes si-toast-in {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes si-toast-out {
  from {
    transform: translateX(0);
    opacity: 1;
  }
  to {
    transform: translateX(100%);
    opacity: 0;
  }
}

.si-toast-success {
  border-left-color: var(--si-success);
}

.si-toast-error {
  border-left-color: var(--si-danger);
}

.si-toast-warning {
  border-left-color: var(--si-warning);
}

.si-toast-info {
  border-left-color: var(--si-info);
}

.si-toast-icon {
  margin-right: 0.75rem;
  font-size: 1.25rem;
}

.si-toast-success .si-toast-icon {
  color: var(--si-success);
}

.si-toast-error .si-toast-icon {
  color: var(--si-danger);
}

.si-toast-warning .si-toast-icon {
  color: var(--si-warning);
}

.si-toast-info .si-toast-icon {
  color: var(--si-info);
}

.si-toast-content {
  flex: 1;
}

.si-toast-title {
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.si-toast-message {
  font-size: 0.875rem;
  color: var(--si-text-secondary);
}

.si-toast-close {
  background: none;
  border: none;
  font-size: 1.25rem;
  color: var(--si-text-secondary);
  cursor: pointer;
  padding: 0;
  margin-left: 0.5rem;
}

.si-toast-close:hover {
  color: var(--si-text-primary);
}

@media (max-width: 767.98px) {
  .si-toast-container {
    left: 10px;
    right: 10px;
    max-width: none;
  }
}

/* ============================================
   FORMS
   ============================================ */
.form-control:focus,
.form-select:focus {
  border-color: var(--si-primary);
  box-shadow: 0 0 0 0.2rem rgba(27, 94, 59, 0.25);
}

/* ============================================
   LOGIN PAGE
   ============================================ */
.login-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--si-primary) 0%, var(--si-primary-hover) 100%);
}

.login-card {
  background: var(--si-bg-white);
  border-radius: 1rem;
  box-shadow: var(--si-shadow);
  padding: 2rem;
  width: 100%;
  max-width: 400px;
}

.login-logo {
  text-align: center;
  margin-bottom: 1.5rem;
}

.login-logo img {
  max-height: 60px;
  width: auto;
}

.login-title {
  text-align: center;
  color: var(--si-primary);
  font-weight: 600;
  margin-bottom: 1.5rem;
}

/* ============================================
   ACTION DROPDOWN (replaces right-click menus)
   ============================================ */
.action-dropdown {
  position: relative;
  display: inline-block;
}

.action-dropdown-btn {
  background: none;
  border: 1px solid var(--si-border-color);
  border-radius: var(--si-border-radius);
  padding: 0.25rem 0.5rem;
  cursor: pointer;
  color: var(--si-text-secondary);
  transition: all 0.2s ease;
}

.action-dropdown-btn:hover {
  background-color: var(--si-bg-light);
  color: var(--si-primary);
  border-color: var(--si-primary);
}

.action-dropdown-menu {
  position: absolute;
  top: 100%;
  right: 0;
  z-index: 1000;
  display: none;
  min-width: 160px;
  padding: 0.5rem 0;
  background-color: var(--si-bg-white);
  border: 1px solid var(--si-border-color);
  border-radius: var(--si-border-radius);
  box-shadow: var(--si-shadow);
}

.action-dropdown.open .action-dropdown-menu {
  display: block;
}

.action-dropdown-item {
  display: block;
  width: 100%;
  padding: 0.5rem 1rem;
  text-align: left;
  background: none;
  border: none;
  color: var(--si-text-primary);
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.action-dropdown-item:hover {
  background-color: var(--si-bg-light);
  color: var(--si-primary);
}

.action-dropdown-item.danger {
  color: var(--si-danger);
}

.action-dropdown-item.danger:hover {
  background-color: rgba(220, 53, 69, 0.1);
}

.action-dropdown-divider {
  height: 1px;
  margin: 0.5rem 0;
  background-color: var(--si-border-color);
}

/* ============================================
   EMPTY STATES
   ============================================ */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--si-text-secondary);
}

.empty-state-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
  opacity: 0.5;
}

.empty-state-title {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--si-text-primary);
}

.empty-state-message {
  margin-bottom: 1rem;
}

/* ============================================
   PRINT STYLES
   ============================================ */
@media print {
  .navbar,
  .sidebar-toggle,
  .action-dropdown,
  .btn {
    display: none !important;
  }
  
  /* .sticky-sidebar override removed to allow mobile scroll/fixed behaviour */
  
  .table {
    font-size: 10pt;
  }
}

/* ============================================
   MOBILE FARM CARDS
   ============================================ */

/* Farm Page Search Bar (Mobile) */
.farm-page-search {
  padding: 1rem;
  padding-bottom: 0.75rem;
  background: var(--si-bg-light);
}

.farm-page-search form {
  width: 100%;
}

.farm-page-search .form-control {
  flex: 1;
  border-radius: var(--si-border-radius);
  font-size: 0.95rem;
}

.farm-page-search .btn {
  white-space: nowrap;
  border-radius: var(--si-border-radius);
  padding: 0.5rem 1rem;
}

/* Hide table on mobile, show cards */
@media (max-width: 991.98px) {
  .desktop-farm-table,
  .desktop-farm-table.view-hidden,
  .desktop-farm-cards,
  .desktop-farm-cards.view-hidden,
  #desktop-farm-cards,
  #desktop-farm-cards:not(.view-hidden),
  div.desktop-farm-cards,
  div#desktop-farm-cards {
    display: none !important;
  }
  .mobile-farm-cards {
    display: block !important;
  }
}

@media (min-width: 992px) {
  .mobile-farm-cards {
    display: none !important;
  }
  .desktop-farm-table {
    display: block;
  }
  .desktop-farm-table.view-hidden {
    display: none !important;
  }
  .desktop-farm-cards.view-hidden {
    display: none !important;
  }
}

/* ============================================
   ANIMAL PAGE VIEW TOGGLE (Desktop)
   ============================================ */

/* Hide desktop elements on mobile, show mobile cards */
@media (max-width: 991.98px) {
  .desktop-animal-table,
  .desktop-card-view,
  #desktop-animal-cards,
  .view-toggle-container {
    display: none !important;
  }
  .mobile-animal-cards {
    display: flex !important;
  }
}

/* Desktop: Hide mobile cards, show desktop toggle */
@media (min-width: 992px) {
  .mobile-animal-cards {
    display: none !important;
  }
  .desktop-animal-table {
    display: block;
  }
  .desktop-animal-table.view-hidden {
    display: none !important;
  }
  #desktop-animal-cards.view-hidden,
  .desktop-card-view.view-hidden {
    display: none !important;
  }
  /* When cards view is active */
  #desktop-animal-cards:not(.view-hidden):not(.d-none) {
    display: block !important;
  }
}

/* Farm Card Container */
.mobile-farm-cards {
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* Individual Farm Card */
.farm-card {
  background: var(--si-bg-white);
  border: 1px solid var(--si-border-color);
  border-radius: var(--si-border-radius);
  box-shadow: var(--si-shadow-sm);
  overflow: hidden;
  transition: box-shadow 0.2s ease;
}

.farm-card:active {
  box-shadow: var(--si-shadow);
}

/* Card Header - Primary Info */
.farm-card-header {
  padding: 1rem;
  background: linear-gradient(135deg, var(--si-primary) 0%, var(--si-primary-hover) 100%);
  color: var(--si-text-light);
}

.farm-card-main {
  margin-bottom: 0.75rem;
}

.farm-name {
  font-size: 1.25rem;
  font-weight: 700;
  margin: 0;
  color: var(--si-text-light);
  line-height: 1.3;
}

/* Badges */
.farm-card-badges {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.farm-card-badges .badge {
  background: rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(10px);
  color: var(--si-text-light);
  padding: 0.375rem 0.75rem;
  border-radius: 1rem;
  font-size: 0.813rem;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  border: 1px solid rgba(255, 255, 255, 0.3);
}

.badge-cows {
  background: rgba(76, 175, 80, 0.3) !important;
}

.badge-scan {
  background: rgba(23, 162, 184, 0.3) !important;
}

/* Toggle Button */
.farm-card-toggle {
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--si-bg-light);
  border: none;
  border-top: 1px solid var(--si-border-color);
  color: var(--si-primary);
  font-weight: 600;
  font-size: 0.875rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.farm-card-toggle:active {
  background: #e9ecef;
}

.farm-card-toggle .toggle-icon {
  transition: transform 0.3s ease;
  font-size: 0.875rem;
}

.farm-card-toggle.expanded .toggle-icon {
  transform: rotate(180deg);
}

/* Detail Section */
.farm-card-details {
  padding: 1rem;
  background: var(--si-bg-white);
  border-top: 1px solid var(--si-border-color);
  animation: slideDown 0.3s ease;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Detail Rows */
.detail-row {
  display: flex;
  justify-content: space-between;
  align-items: start;
  padding: 0.625rem 0;
  border-bottom: 1px solid #f1f3f5;
}

.detail-row:last-of-type {
  border-bottom: none;
}

.detail-label {
  font-weight: 600;
  color: var(--si-text-secondary);
  font-size: 0.875rem;
  min-width: 100px;
}

.detail-value {
  color: var(--si-text-primary);
  font-size: 0.875rem;
  text-align: right;
  flex: 1;
  word-break: break-word;
}

.btn-link-calls,
.btn-link-animals {
  color: var(--si-primary);
  text-decoration: none;
  font-weight: 600;
  padding: 0.25rem 0.5rem;
  border-radius: 0.25rem;
  transition: background 0.2s ease;
}

.btn-link-calls:hover,
.btn-link-animals:hover {
  background: var(--si-bg-light);
  color: var(--si-primary-hover);
}

/* Action Buttons */
.farm-card-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 2px solid var(--si-border-color);
}

.action-btn {
  padding: 0.625rem 1rem;
  border: none;
  border-radius: var(--si-border-radius);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  text-decoration: none;
}

.action-btn-primary {
  background: var(--si-primary);
  color: white;
}

.action-btn-primary:active {
  background: var(--si-primary-hover);
  transform: scale(0.98);
}

.action-btn-secondary {
  background: var(--si-secondary);
  color: white;
}

.action-btn-secondary:active {
  background: var(--si-secondary-hover);
  transform: scale(0.98);
}

.action-btn-success {
  background: var(--si-success);
  color: white;
}

.action-btn-success:hover {
  color: white;
  text-decoration: none;
}

.action-btn-success:active {
  background: #218838;
  transform: scale(0.98);
}

.action-btn-info {
  background: var(--si-info);
  color: white;
}

.action-btn-info:active {
  background: #138496;
  transform: scale(0.98);
}

.action-btn-danger {
  background: var(--si-danger);
  color: white;
}

.action-btn-danger:active {
  background: #c82333;
  transform: scale(0.98);
}

/* ============================================
   CALL CARDS (Mobile View)
   ============================================ */

/* Call Page Mobile Search Bar */
.call-page-search {
  padding: 0.5rem 0;
  background: var(--si-bg-white);
  border-radius: var(--si-border-radius);
  box-shadow: var(--si-shadow-sm);
  padding: 1rem;
}

.call-page-search .input-group {
  box-shadow: var(--si-shadow-sm);
  border-radius: var(--si-border-radius);
  overflow: hidden;
}

/* Mobile Call Cards Container */
@media (min-width: 992px) {
  .mobile-call-cards {
    display: none;
  }
}

@media (max-width: 991.98px) {
  .mobile-call-cards {
    display: block;
  }
}

.mobile-call-cards {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* Individual Call Card */
.call-card {
  background: white;
  border-radius: var(--si-border-radius);
  box-shadow: var(--si-shadow-sm);
  overflow: hidden;
  transition: all 0.2s ease;
}

.call-card:active {
  transform: scale(0.98);
  box-shadow: var(--si-shadow);
}

/* Call Card Header (Clickable) */
.call-card-header {
  background: linear-gradient(135deg, var(--si-primary) 0%, var(--si-primary-hover) 100%);
  color: white;
  padding: 1rem;
  cursor: pointer;
  transition: background 0.2s ease;
}

.call-card-header:active {
  background: var(--si-primary-hover);
}

.call-card-header h5 {
  font-size: 1.125rem;
  font-weight: 600;
  margin: 0;
  color: white;
}

.call-card-header .badge {
  font-size: 0.75rem;
  font-weight: 600;
}

/* Call Card Toggle Button */
.call-card-toggle {
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--si-bg-light);
  border: none;
  border-top: 1px solid var(--si-border-color);
  color: var(--si-primary);
  font-weight: 600;
  font-size: 0.875rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.call-card-toggle:active {
  background: #e9ecef;
}

.call-card-toggle .toggle-icon {
  transition: transform 0.3s ease;
  font-size: 0.875rem;
}

.call-card-toggle.expanded .toggle-icon {
  transform: rotate(180deg);
}

/* Call Details Section */
.call-card-details {
  padding: 1rem;
  background: var(--si-bg-white);
  border-top: 1px solid var(--si-border-color);
  animation: slideDown 0.3s ease;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.detail-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--si-border-color);
}

.detail-row:last-child {
  border-bottom: none;
}

.detail-label {
  font-weight: 600;
  color: var(--si-text-secondary);
  font-size: 0.875rem;
}

.detail-value {
  color: var(--si-text-primary);
  font-weight: 500;
  text-align: right;
}

.detail-value a {
  color: var(--si-primary);
  text-decoration: none;
  font-weight: 600;
}

.detail-value a:hover {
  color: var(--si-primary-hover);
  text-decoration: underline;
}

/* Call Action Buttons */
.call-card-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 2px solid var(--si-border-color);
}

.call-card-actions > .action-btn {
  width: 100%;
}

/* Make first button (View Scans) span full width */
.call-card-actions > .action-btn:nth-child(1) {
  grid-column: 1 / -1;
}

/* Action button row for Update & Delete */
.action-btn-row {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.action-btn-row .action-btn {
  width: 100%;
}

.action-btn-row .action-btn {
  width: 100%;
}

/* ============================================
   HERD INFO SECTION (Animals Page)
   ============================================ */

.herd-info-section {
  padding: 1rem;
}

/* Three Column Layout */
.herd-info-columns {
  display: grid;
  grid-template-columns: max-content max-content max-content max-content;
  justify-content: start;
  align-items: start;
  column-gap: 1rem;
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

@media (max-width: 1200px) {
  .herd-info-columns {
    grid-template-columns: max-content max-content max-content max-content;
    justify-content: start;
    column-gap: 1rem;
  }
}

@media (max-width: 768px) {
  .herd-info-columns {
    grid-template-columns: 1fr;
    gap: 0.25rem;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
  }
}

/* Column Styling */
.herd-column {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding-right: 0;
  border-right: none;
}

.herd-column:last-child {
  padding-right: 0;
  border-right: none;
}

.herd-legend-column {
  gap: 0;
  padding-right: 0;
  border-right: none;
}
.info-item {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  font-size: 0.875rem;
  line-height: 1.3;
}

.info-item strong {
  color: var(--si-text-secondary);
  font-weight: 700;
  font-size: 1.1rem;
  white-space: nowrap;
  flex-shrink: 0;
}

.info-item span {
  color: var(--si-text-primary);
  font-size: 1rem;
  overflow: hidden;
  text-overflow: ellipsis;
  word-break: break-word;
}

/* Checkboxes */
.herd-checkboxes {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  margin-bottom: 0.75rem;
}

.herd-checkboxes .form-check {
  margin-bottom: 0;
}

.herd-checkboxes .form-check-label {
  font-size: 1rem;
  margin-left: 0.25rem;
}

/* Action Buttons */
.herd-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.herd-actions .btn {
  width: 100%;
  padding: 0.5rem 0.75rem;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  background-color: var(--si-primary);
  border-color: var(--si-primary);
  color: white;
}

.herd-actions .btn:hover {
  background-color: var(--si-primary-hover);
  border-color: var(--si-primary-hover);
  color: white;
}

.herd-actions .btn .bi {
  font-size: 1rem;
}

/* Color Legend */
.herd-legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
}

.legend-title {
  font-weight: 600;
  color: var(--si-text-secondary);
  font-size: 0.875rem;
  margin: 0;
}

.colour-legend {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.colour-legend-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.colour-legend-box {
  width: 24px;
  height: 24px;
  border-radius: 4px;
  border: 1px solid var(--si-border-color);
  flex-shrink: 0;
}

.colour-legend-box.registered {
  background-color: var(--si-row-registered);
}

.colour-legend-box.unregistered {
  background-color: var(--si-row-unregistered);
}

.colour-legend-text {
  font-size: 1.05rem;
  color: var(--si-text-primary);
}

/* Mobile Offcanvas Fix - Ensure backdrop doesn't stay */
.offcanvas-backdrop {
  z-index: 1040;
}

.offcanvas {
  z-index: 1045;
}

/* Mobile Pagination */
@media (max-width: 991.98px) {
  .pagination {
    font-size: 0.875rem;
  }
  
  .pagination .page-item .page-link {
    padding: 0.5rem 0.75rem;
  }
}

/* ============================================
   SCAN PAGE SPECIFIC STYLES
   ============================================ */

/* Scan page sidebar */
.scan-sidebar {
  overflow-y: auto;
}

/* Mobile scan page adjustments */
@media (max-width: 991.98px) {
  /* Make scan table full width on mobile */
  .scan-sidebar {
    padding-top: 3rem; /* Space for close button */
  }
  
  /* Scan page info section mobile */
  .d-flex.flex-wrap.align-items-start.border {
    flex-direction: column;
  }
  
  .d-flex.flex-wrap.align-items-start.border > div {
    margin-bottom: 0.75rem;
    margin-right: 0 !important;
  }
  
  /* Scan form compact on mobile */
  .scan-sidebar .form-group {
    margin-bottom: 0.5rem;
  }
  
  .scan-sidebar .p-2.mb-2.rounded {
    padding: 0.5rem !important;
    margin-bottom: 0.5rem !important;
  }
  
  .scan-sidebar .p-2.mb-2.rounded .row {
    margin-left: 0;
    margin-right: 0;
  }
}

/* ============================================
   ANIMALS PAGE MOBILE STYLES
   ============================================ */

@media (max-width: 991.98px) {
  /* Herd info section mobile layout */
  .herd-info-section {
    padding: 0.75rem;
  }
  
  .herd-info-columns {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
  }
  
  .herd-column {
    padding-right: 0;
    border-right: none;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--si-border-color);
  }
  
  .herd-column:last-child {
    border-bottom: none;
    padding-bottom: 0;
  }
  
  /* Colour legend compact on mobile */
  .colour-legend {
    flex-direction: row;
    gap: 0.75rem;
    flex-wrap: wrap;
    padding: 0.5rem;
  }
  
  .colour-legend-item {
    gap: 0.35rem;
  }
  
  .colour-legend-box {
    width: 18px;
    height: 18px;
  }
  
  .colour-legend-text {
    font-size: 0.875rem;
  }
  
  /* Action buttons stack on mobile */
  .herd-actions {
    grid-template-columns: 1fr;
    gap: 0.5rem;
  }
  
  /* Info items compact */
  .info-item {
    font-size: 0.8125rem;
  }
  
  .info-item strong {
    font-size: 0.875rem;
  }
}

/* ============================================
   GENERAL MOBILE IMPROVEMENTS
   ============================================ */

@media (max-width: 575.98px) {
  /* Extra small devices */
  .container-fluid {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
  }
  
  h2.fw-bold {
    font-size: 1.5rem;
  }
  
  /* Buttons full width on very small screens */
  .btn-primary,
  .btn-outline-primary {
    padding: 0.5rem 0.75rem;
  }
  
  /* Form controls */
  .form-control,
  .form-select {
    font-size: 0.875rem;
  }
}

/* Ensure sidebar toggle is visible and properly styled */
.sidebar-toggle {
  display: none;
}

@media (max-width: 991.98px) {
  .sidebar-toggle {
    display: flex !important;
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background-color: var(--si-primary);
    color: var(--si-text-light);
    border: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
    z-index: 1030;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    cursor: pointer;
    transition: transform 0.2s ease, background-color 0.2s ease;
  }
  
  .sidebar-toggle:hover,
  .sidebar-toggle:active {
    background-color: var(--si-primary-hover);
    transform: scale(1.05);
  }
}

/* Close button styling */
.sidebar-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background-color: var(--si-bg-light);
  border: 1px solid var(--si-border-color);
  color: var(--si-text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 10;
  transition: all 0.2s ease;
}

.sidebar-close:hover {
  background-color: var(--si-danger);
  color: white;
  border-color: var(--si-danger);
}

/* ============================================
   MOBILE BOTTOM NAVIGATION
   ============================================ */

.mobile-bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 60px;
  background-color: var(--si-bg-white);
  border-top: 1px solid var(--si-border-color);
  display: flex;
  justify-content: space-around;
  align-items: center;
  z-index: 1020;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
}

.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--si-text-secondary);
  text-decoration: none;
  padding: 8px 16px;
  border-radius: var(--si-border-radius);
  transition: all 0.2s ease;
  font-size: 0.75rem;
}

.bottom-nav-item i {
  font-size: 1.25rem;
  margin-bottom: 2px;
}

.bottom-nav-item.active,
.bottom-nav-item:hover {
  color: var(--si-primary);
  background-color: rgba(27, 94, 59, 0.1);
}

.bottom-nav-item.active i {
  color: var(--si-primary);
}

/* Add bottom padding to body when bottom nav is present */
@media (max-width: 991.98px) {
  body {
    padding-bottom: 70px;
  }
  
  /* Adjust sidebar toggle position to account for bottom nav */
  .sidebar-toggle {
    bottom: 80px !important;
  }
}

/* ============================================
   MOBILE ANIMAL CARDS
   ============================================ */

.mobile-animal-cards {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding-bottom: 1rem;
}

.animal-card {
  background: var(--si-bg-white);
  border-radius: var(--si-border-radius);
  box-shadow: var(--si-shadow-sm);
  overflow: hidden;
  border-left: 4px solid var(--si-success);
  transition: all 0.2s ease;
}

.animal-card.selected {
  box-shadow: 0 0 0 2px var(--si-primary);
}

.animal-card-registered {
  border-left-color: var(--si-success);
}

.animal-card-unregistered {
  border-left-color: var(--si-danger);
}

.animal-card-header {
  padding: 0.875rem 1rem;
  cursor: pointer;
  background-color: var(--si-bg-white);
}

.animal-card-header:active {
  background-color: var(--si-bg-light);
}

.animal-card-main {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.5rem;
}

.animal-card-id {
  display: flex;
  flex-direction: column;
}

.animal-tag {
  font-weight: 700;
  font-size: 1rem;
  color: var(--si-text-primary);
}

.animal-fb {
  font-size: 0.875rem;
  color: var(--si-text-secondary);
}

.animal-card-status .badge {
  font-size: 0.7rem;
  padding: 0.25rem 0.5rem;
}

.animal-card-scan {
  font-size: 0.8125rem;
  color: var(--si-text-secondary);
  display: flex;
  align-items: center;
  gap: 0.375rem;
}

.animal-card-scan i {
  color: var(--si-primary);
}

.animal-card-toggle {
  width: 100%;
  padding: 0.5rem 1rem;
  background: var(--si-bg-light);
  border: none;
  border-top: 1px solid var(--si-border-color);
  color: var(--si-primary);
  font-weight: 600;
  font-size: 0.8125rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.animal-card-toggle:active {
  background: #e9ecef;
}

.animal-card-toggle .toggle-icon {
  transition: transform 0.3s ease;
  font-size: 0.75rem;
}

.animal-card-toggle.expanded .toggle-icon {
  transform: rotate(180deg);
}

.animal-card-details {
  padding: 0.875rem 1rem;
  background: var(--si-bg-light);
  border-top: 1px solid var(--si-border-color);
}

.animal-detail-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem 0.5rem;
  padding: 0.5rem 0;
}

.animal-detail-grid .detail-item {
  display: flex;
  flex-direction: column;
  text-align: center;
  padding: 0.25rem;
  background: rgba(0,0,0,0.02);
  border-radius: 4px;
}

.animal-detail-grid .detail-label {
  font-size: 0.6rem;
  color: var(--si-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 0.15rem;
  font-weight: 600;
}

.animal-detail-grid .detail-value {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--si-text-primary);
  line-height: 1.2;
}

/* ============================================
   MOBILE SCAN PAGE IMPROVEMENTS
   ============================================ */

@media (max-width: 991.98px) {
  /* Scan table - make it more compact and prevent horizontal scroll */
  #scanTable {
    font-size: 0.8125rem;
    width: 100%;
    table-layout: auto;
  }
  
  #scanTable th,
  #scanTable td {
    padding: 0.375rem 0.5rem;
    white-space: normal; /* Allow text wrapping */
    word-break: break-word;
  }
  
  /* Hide less important columns on mobile to fit table */
  #scanTable th:nth-child(4),
  #scanTable td:nth-child(4),
  #scanTable th:nth-child(5),
  #scanTable td:nth-child(5) {
    display: none;
  }
  
  /* Remove horizontal scroll indicator - table should fit */
  .table-responsive-wrapper {
    overflow-x: visible;
  }
  
  /* Scan sidebar improvements */
  .scan-sidebar .form-control-sm,
  .scan-sidebar .form-select-sm {
    font-size: 0.875rem;
    padding: 0.375rem 0.5rem;
  }
  
  .scan-sidebar label {
    font-size: 0.75rem;
  }
  
  /* Classification dropdowns more compact */
  .scan-sidebar .form-group[style*="flex: 1 1"] {
    flex: 1 1 30% !important;
  }
}

/* ============================================
   IMPROVED LOADING STATES
   ============================================ */

/* Skeleton loading animation */
@keyframes skeleton-loading {
  0% {
    background-position: -200px 0;
  }
  100% {
    background-position: calc(200px + 100%) 0;
  }
}

.skeleton {
  background: linear-gradient(
    90deg,
    #f0f0f0 25%,
    #e0e0e0 50%,
    #f0f0f0 75%
  );
  background-size: 200px 100%;
  animation: skeleton-loading 1.5s ease-in-out infinite;
  border-radius: var(--si-border-radius);
}

.skeleton-text {
  height: 1rem;
  margin-bottom: 0.5rem;
}

.skeleton-text-sm {
  height: 0.75rem;
  width: 60%;
}

/* ============================================
   ENHANCED FORM STYLES
   ============================================ */

/* Better focus states */
.form-control:focus,
.form-select:focus {
  border-color: var(--si-primary);
  box-shadow: 0 0 0 0.2rem rgba(27, 94, 59, 0.25);
}

/* Input validation states */
.form-control.is-valid {
  border-color: var(--si-success);
}

.form-control.is-invalid {
  border-color: var(--si-danger);
}

/* Better checkbox styling */
.form-check-input:checked {
  background-color: var(--si-primary);
  border-color: var(--si-primary);
}

.form-check-input:focus {
  border-color: var(--si-primary);
  box-shadow: 0 0 0 0.2rem rgba(27, 94, 59, 0.25);
}

/* ============================================
   MICRO-INTERACTIONS
   ============================================ */

/* Button press effect */
.btn:active {
  transform: scale(0.98);
}

/* Card hover lift effect (desktop only) */
@media (min-width: 992px) {
  .farm-card:hover,
  .call-card:hover,
  .animal-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--si-shadow);
  }
}

/* Link hover transitions */
a {
  transition: color 0.2s ease;
}

/* Badge pulse for important items */
@keyframes badge-pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.7;
  }
}

.badge-pulse {
  animation: badge-pulse 2s ease-in-out infinite;
}

/* ============================================
   IMPROVED ACCESSIBILITY
   ============================================ */

/* Focus visible for keyboard navigation */
*:focus-visible {
  outline: 2px solid var(--si-primary);
  outline-offset: 2px;
}

/* Skip link for accessibility */
.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: var(--si-primary);
  color: white;
  padding: 8px;
  z-index: 100;
  transition: top 0.3s;
}

.skip-link:focus {
  top: 0;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  :root {
    --si-primary: #0d4020;
    --si-border-color: #000;
  }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ============================================
   PRINT STYLES
   ============================================ */

@media print {
  .mobile-bottom-nav,
  .sidebar-toggle,
  .sidebar-overlay,
  .navbar-toggler {
    display: none !important;
  }
  
  .sticky-sidebar {
    position: static;
    width: 100%;
  }
  
  .table {
    font-size: 10pt;
  }
}

/* ============================================
   MOBILE SCAN CARDS
   ============================================ */

.mobile-scan-cards {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.scan-card {
  background: white;
  border: 1px solid var(--si-border-color);
  border-left: 4px solid var(--si-primary);
  border-radius: var(--si-border-radius);
  padding: 0.75rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.scan-card:active {
  transform: scale(0.98);
}

.scan-card.selected {
  border-color: var(--si-primary);
  box-shadow: 0 0 0 2px rgba(0, 128, 96, 0.2);
}

.scan-card-warning {
  border-left-color: #ffc107;
  background-color: #fffbeb;
}

.scan-card-header {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.scan-card-main {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.scan-card-id {
  display: flex;
  flex-direction: column;
}

.scan-tag {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--si-text-primary);
}

.scan-fb {
  font-size: 0.8rem;
  color: var(--si-text-secondary);
}

.scan-card-code .badge {
  font-size: 0.75rem;
}

.scan-card-details {
  display: flex;
  gap: 1rem;
  font-size: 0.8rem;
  color: var(--si-text-secondary);
}

.scan-card-details .detail-item strong {
  color: var(--si-text-primary);
}

.scan-card-status {
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--si-border-color);
}

.scan-card-status .scan-check-label {
  padding: 0.25rem 0.75rem;
  font-size: 0.75rem;
}

/* Mobile Scan Pagination */
.mobile-scan-pagination {
  background: white;
  border-radius: var(--si-border-radius);
  padding: 0.5rem;
  margin-top: 0.5rem;
}

/* ============================================
   VIDEO PLAYER - MATCH ORIGINAL RENDERING
   ============================================ */

/* Video player wrapper */
.video-player-wrapper {
  width: 100%;
  background-color: #000;
  overflow: hidden;
  border-radius: var(--si-border-radius);
}

/* Mobile only (<768px): Stack video and form vertically */
@media (max-width: 767.98px) {
  #video-panel .video-column,
  #video-panel .form-column,
  #video-panel .col-md-6 {
    width: 100% !important;
    flex: 0 0 100% !important;
    max-width: 100% !important;
  }
  
  #video-panel .video-column,
  #video-panel .col-md-6:first-child {
    margin-bottom: 1rem;
  }
  
  #video-player {
    width: 100% !important;
    height: auto !important;
    min-height: 200px;
    object-fit: fill !important;
  }
}

/* iPad/Tablet (768px-991px): 50/50 split like desktop */
@media (min-width: 768px) and (max-width: 991.98px) {
  #video-panel .video-column,
  #video-panel .form-column,
  #video-panel .col-md-6 {
    width: 50% !important;
    flex: 0 0 50% !important;
    max-width: 50% !important;
  }
  
  #video-player {
    width: 100% !important;
    height: auto !important;
    object-fit: fill !important;
  }
}

/* Desktop (992px+): 50/50 split like original - let Bootstrap col-md-6 work */
@media (min-width: 992px) {
  #video-panel .video-column,
  #video-panel .form-column {
    width: 50%;
    flex: 0 0 50%;
    max-width: 50%;
  }
}

/* ============================================
   FIX: COLLAPSIBLE BUTTON TOGGLE ICON
   ============================================ */

[data-bs-toggle="collapse"] .bi-chevron-down {
  transition: transform 0.3s ease;
}

[data-bs-toggle="collapse"][aria-expanded="true"] .bi-chevron-down,
[data-bs-toggle="collapse"]:not(.collapsed) .bi-chevron-down {
  transform: rotate(180deg);
}

/* Also handle .collapsed class that Bootstrap adds */
.collapsed .bi-chevron-down {
  transform: rotate(0deg) !important;
}

button:not(.collapsed)[data-bs-toggle="collapse"] .bi-chevron-down {
  transform: rotate(180deg);
}

/* ============================================
   HINT TEXT STYLING
   ============================================ */

.alert-info {
  background-color: #e8f4f8;
  border-color: #bee5eb;
  color: #0c5460;
}

.alert-info .bi {
  color: var(--si-primary);
}

/* ============================================
   MOBILE GROUP CARDS
   ============================================ */

/* Hide desktop group cards and table on mobile screens */
@media (max-width: 991.98px) {
  .desktop-group-cards,
  #desktop-group-cards {
    display: none !important;
  }
  
  #callTable {
    display: none !important;
  }
}

.mobile-group-cards {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.group-card {
  background: white;
  border: 1px solid var(--si-border-color);
  border-left: 4px solid var(--si-primary);
  border-radius: var(--si-border-radius);
  padding: 1rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.group-card:active {
  transform: scale(0.98);
}

.group-card.selected {
  border-color: var(--si-primary);
  box-shadow: 0 0 0 2px rgba(0, 128, 96, 0.2);
}

.group-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.75rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--si-border-color);
}

.group-card-id {
  display: flex;
  flex-direction: column;
}

.group-id-label {
  font-size: 0.7rem;
  color: var(--si-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.group-id-value {
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--si-text-primary);
  word-break: break-all;
}

.group-card-scans .btn {
  white-space: nowrap;
}

.group-card-details {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.group-card-details .detail-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
}

.group-card-details .detail-label {
  color: var(--si-text-secondary);
}

.group-card-details .detail-label .bi {
  color: var(--si-primary);
}

.group-card-details .detail-value {
  color: var(--si-text-primary);
  font-weight: 500;
  text-align: right;
}

/* ============================================
   DESKTOP CARD VIEW WITH TOGGLE
   ============================================ */

/* View Toggle Button */
.view-toggle-container {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 1rem;
  gap: 0.5rem;
}

.view-toggle-btn {
  padding: 0.5rem 1rem;
  border: 1px solid var(--si-border-color);
  background: white;
  border-radius: var(--si-border-radius);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  color: var(--si-text-secondary);
  transition: all 0.2s ease;
}

.view-toggle-btn:hover {
  border-color: var(--si-primary);
  color: var(--si-primary);
}

.view-toggle-btn.active {
  background: var(--si-primary);
  color: white;
  border-color: var(--si-primary);
}

/* Desktop Card Grid */
.desktop-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1rem;
}

/* Hide/Show based on view mode */
.view-table-mode .desktop-card-view {
  display: none !important;
}

.view-table-mode .desktop-table-view {
  display: block !important;
}

.view-card-mode .desktop-card-view {
  display: block !important;
}

.view-card-mode .desktop-table-view {
  display: none !important;
}

/* Default: Table mode on desktop */
@media (min-width: 992px) {
  .desktop-card-view {
    display: none;
  }
  
  .desktop-table-view {
    display: block;
  }
}

/* Desktop Cards - larger and optimized for desktop */
@media (min-width: 992px) {
  .desktop-card-grid .animal-card,
  .desktop-card-grid .scan-card,
  .desktop-card-grid .group-card,
  .desktop-card-grid .call-card,
  .desktop-card-grid .farm-card {
    margin-bottom: 0;
    min-height: 200px;
  }
  
  /* Increase gap for desktop call cards */
  #desktop-call-cards .desktop-card-grid {
    gap: 1.5rem;
    margin-bottom: 2rem;
  }
  
  #desktop-call-cards {
    margin-bottom: 2rem;
  }
  
  .desktop-card-grid .animal-card-header,
  .desktop-card-grid .scan-card-header,
  .desktop-card-grid .group-card-header {
    padding: 1rem 1.25rem;
  }
  
  .desktop-card-grid .animal-card-tag,
  .desktop-card-grid .scan-card-tag {
    font-size: 1.1rem;
  }
  
  /* Better text alignment in desktop cards */
  .desktop-card-grid .animal-card-details,
  .desktop-card-grid .farm-card-details,
  .desktop-card-grid .call-card-details {
    padding: 1rem 1.25rem;
  }
  
  /* Desktop Animal Card Details - Optimized layout */
  .desktop-card-grid .animal-detail-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
    padding: 0.5rem 0;
  }
  
  .desktop-card-grid .animal-detail-grid .detail-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 0.4rem 0.3rem;
    background: rgba(0,0,0,0.03);
    border-radius: 4px;
    min-height: 50px;
  }
  
  .desktop-card-grid .animal-detail-grid .detail-label {
    font-size: 0.6rem;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    font-weight: 600;
    margin-bottom: 0.15rem;
    white-space: nowrap;
  }
  
  .desktop-card-grid .animal-detail-grid .detail-value {
    font-size: 0.75rem;
    color: #212529;
    font-weight: 500;
    line-height: 1.2;
    word-break: break-word;
  }
}

/* ============================================
   FIX: SIDEBAR INITIALIZATION
   ============================================ */

/* Ensure sidebar elements exist and are styled correctly */
.sticky-sidebar {
  background-color: white;
}

/* Mobile sidebar overlay - higher z-index */
.sidebar-overlay {
  z-index: 1040;
}

.sticky-sidebar.show {
  z-index: 1050;
}

/* Sidebar close button styling */
.sidebar-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 32px;
  height: 32px;
  border: none;
  background: #f0f0f0;
  border-radius: 50%;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--si-text-secondary);
  z-index: 10;
}

.sidebar-close:hover {
  background: #e0e0e0;
  color: var(--si-text-primary);
}

@media (min-width: 992px) {
  .sidebar-close {
    display: none;
  }
}

/* ============================================
   GROUPS PAGE FIX
   ============================================ */

/* Ensure Groups table is visible on desktop */
@media (min-width: 992px) {
  #callTable {
    display: table;
  }
  
  #callTable tbody tr {
    display: table-row;
  }
  
  #callTable.view-hidden {
    display: none !important;
  }
  
  .desktop-group-cards.view-hidden {
    display: none !important;
  }
}

/* ============================================
   DESKTOP FARM CARDS
   ============================================ */

.desktop-farm-cards {
  padding: 1rem 0;
}

.desktop-farm-cards .farm-card {
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.desktop-farm-cards .farm-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.desktop-farm-cards .farm-card.selected {
  border: 2px solid var(--si-primary);
}

.desktop-farm-cards .farm-card-details {
  padding: 0.75rem 1rem;
}

.desktop-farm-cards .farm-card-actions {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--si-border-color);
  flex-wrap: wrap;
}

.desktop-farm-cards .action-btn {
  padding: 0.375rem 0.75rem;
  font-size: 0.8rem;
  border: 1px solid var(--si-border-color);
  border-radius: var(--si-border-radius);
  background: white;
  color: var(--si-text-primary);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  cursor: pointer;
}

.desktop-farm-cards .action-btn:hover {
  background: var(--si-bg-light);
  border-color: var(--si-primary);
  color: var(--si-primary);
}

/* Force SIConfirm green button to use a true green */
.btn-success, .modal-footer .btn-success, .modal-footer .btn-success:focus, .modal-footer .btn-success:active, .modal-footer .btn-success:hover {
  background-color: #28a745 !important;
  border-color: #28a745 !important;
  color: #fff !important;
  box-shadow: none !important;
}
