/* Trainly Styles */

:root {
  /* Brand Colors */
  --primary: #6f42c1;
  --primary-dark: #5a359a;
  --primary-light: rgba(111, 66, 193, 0.1);
  --secondary: #6c757d;
  --success: #198754;
  --info: #0dcaf0;
  --warning: #ffc107;
  --danger: #dc3545;
  --light: #f8f9fa;
  --dark: #212529;
  
  /* Brand variable aliases for compatibility */
  --brand-primary: var(--primary);
  --brand-primary-dark: var(--primary-dark);
  --brand-light: var(--primary-light);
  --brand-secondary: var(--secondary);
  --brand-success: var(--success);
  --brand-warning: var(--warning);
  --brand-danger: var(--danger);
  --brand-dark: var(--dark);
  
  /* Mobile-First Breakpoints */
  --breakpoint-sm: 576px;
  --breakpoint-md: 768px;
  --breakpoint-lg: 992px;
  --breakpoint-xl: 1200px;
  --breakpoint-xxl: 1400px;
  
  /* Mobile-First Typography */
  --font-size-xs: 0.75rem;
  --font-size-sm: 0.875rem;
  --font-size-base: 1rem;
  --font-size-lg: 1.125rem;
  --font-size-xl: 1.25rem;
  --font-size-xxl: 1.5rem;
  --line-height-tight: 1.25;
  --line-height-base: 1.5;
  --line-height-relaxed: 1.75;
  
  /* Mobile-First Spacing */
  --spacing-xs: 0.25rem;
  --spacing-sm: 0.5rem;
  --spacing-md: 1rem;
  --spacing-lg: 1.5rem;
  --spacing-xl: 2rem;
  --spacing-xxl: 3rem;
  
  /* Touch-Friendly Sizes */
  --touch-target-sm: 40px;
  --touch-target-md: 44px;
  --touch-target-lg: 48px;
  --button-height-sm: 32px;
  --button-height-md: 40px;
  --button-height-lg: 48px;
  
  /* Border and Shadow */
  --border-radius-sm: 0.25rem;
  --border-radius: 0.375rem;
  --border-radius-lg: 0.5rem;
  --border-radius-xl: 0.75rem;
  --border-radius-pill: 50rem;
  --box-shadow-sm: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
  --box-shadow: 0 0.25rem 0.5rem rgba(0, 0, 0, 0.1);
  --box-shadow-lg: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
  --box-shadow-xl: 0 1rem 2rem rgba(0, 0, 0, 0.2);
  
  /* Mobile-Specific Variables */
  --navbar-height-mobile: 60px;
  --navbar-height-desktop: 70px;
  --sidebar-width: 280px;
  --bottom-action-bar-height: 72px;
  --mobile-padding: var(--spacing-md);
  --desktop-padding: var(--spacing-lg);
  
  /* Z-Index Scale */
  --z-dropdown: 1000;
  --z-sticky: 1020;
  --z-fixed: 1030;
  --z-modal-backdrop: 1040;
  --z-modal: 1050;
  --z-popover: 1060;
  --z-tooltip: 1070;
}

/* Global Styles */
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: var(--font-size-sm);
  line-height: var(--line-height-base);
  background-color: #f8f9fc;
  padding-top: var(--navbar-height-mobile);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  touch-action: manipulation;
}

@media (min-width: 768px) {
  body {
    font-size: var(--font-size-base);
    padding-top: var(--navbar-height-desktop);
  }
}

/* Navigation */
.navbar {
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.navbar-brand {
  font-size: 1.25rem;
  font-weight: 600;
}

.nav-link {
  display: flex;
  align-items: center;
  font-weight: 500;
}

.nav-link:hover {
  background-color: rgba(255, 255, 255, 0.1);
  border-radius: 0.375rem;
}

.dropdown-menu {
  border: none;
  box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
  border-radius: 0.5rem;
  margin-top: 0.5rem;
}

.dropdown-item {
  padding: 0.5rem 1rem;
  font-weight: 500;
  transition: all 0.2s ease-in-out;
}

.dropdown-item:hover {
  background-color: var(--primary);
  color: white;
  transform: translateX(2px);
}

/* Main Content */
.main-content {
  margin-top: 76px;
  min-height: calc(100vh - 76px);
  display: flex;
  flex-direction: column;
}

.content-wrapper {
  flex: 1;
  padding: 1.5rem;
}

/* Mobile-First Cards */
.card {
  border: none;
  border-radius: var(--border-radius-lg);
  box-shadow: var(--box-shadow);
  transition: all 0.2s ease-in-out;
  margin-bottom: var(--spacing-md);
  overflow: hidden;
}

@media (min-width: 768px) {
  .card:hover {
    box-shadow: var(--box-shadow-lg);
    transform: translateY(-1px);
  }
}

.card-header {
  background-color: #f8f9fc;
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
  font-weight: 600;
  color: var(--dark);
  padding: var(--spacing-md);
}

@media (min-width: 768px) {
  .card-header {
    padding: var(--spacing-lg);
  }
}

.card-body {
  padding: var(--spacing-md);
}

@media (min-width: 768px) {
  .card-body {
    padding: var(--spacing-lg);
  }
}

.card-footer {
  background-color: #f8f9fc;
  border-top: 1px solid rgba(0, 0, 0, 0.05);
  padding: var(--spacing-md);
}

@media (min-width: 768px) {
  .card-footer {
    padding: var(--spacing-lg);
  }
}

.card-title {
  color: var(--dark);
  font-weight: 600;
  margin-bottom: var(--spacing-sm);
  font-size: var(--font-size-lg);
  line-height: var(--line-height-tight);
}

.card-compact {
  border-radius: var(--border-radius);
}

.card-compact .card-header,
.card-compact .card-body,
.card-compact .card-footer {
  padding: var(--spacing-sm);
}

.card-stats {
  text-align: center;
  padding: var(--spacing-md);
}

.card-stats .stat-value {
  font-size: var(--font-size-xxl);
  font-weight: 700;
  line-height: 1;
  margin-bottom: var(--spacing-xs);
}

.card-stats .stat-label {
  font-size: var(--font-size-xs);
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 0.05em;
  opacity: 0.8;
}

/* Mobile-First Buttons */
.btn {
  border-radius: var(--border-radius);
  font-weight: 500;
  transition: all 0.2s ease-in-out;
  min-height: var(--touch-target-md);
  padding: var(--spacing-sm) var(--spacing-md);
  font-size: var(--font-size-sm);
  line-height: var(--line-height-tight);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
  user-select: none;
}

@media (min-width: 768px) {
  .btn {
    min-height: var(--button-height-md);
    font-size: var(--font-size-base);
  }
  
  .btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--box-shadow);
  }
}

.btn-sm {
  min-height: var(--touch-target-sm);
  padding: var(--spacing-xs) var(--spacing-sm);
  font-size: var(--font-size-xs);
}

.btn-lg {
  min-height: var(--touch-target-lg);
  padding: var(--spacing-md) var(--spacing-lg);
  font-size: var(--font-size-lg);
}

.btn-icon {
  width: var(--touch-target-md);
  height: var(--touch-target-md);
  padding: 0;
  border-radius: var(--border-radius-lg);
}

.btn-floating {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  box-shadow: var(--box-shadow-lg);
  position: fixed;
  bottom: var(--spacing-lg);
  right: var(--spacing-lg);
  z-index: var(--z-fixed);
}

.btn-primary {
  background-color: var(--primary);
  border-color: var(--primary);
}

.btn-primary:hover {
  background-color: var(--primary-dark);
  border-color: var(--primary-dark);
}

.btn-success {
  background-color: var(--success);
  border-color: var(--success);
}

.btn-info {
  background-color: var(--info);
  border-color: var(--info);
}

.btn-warning {
  background-color: var(--warning);
  border-color: var(--warning);
  color: var(--dark);
}

.btn-danger {
  background-color: var(--danger);
  border-color: var(--danger);
}

/* Tables */
.table {
  margin-bottom: 0;
}

.table th {
  border-top: none;
  font-weight: 600;
  color: var(--dark);
  background-color: #f8f9fc;
  padding: 1rem 0.75rem;
}

.table td {
  padding: 0.75rem;
  vertical-align: middle;
}

.table-hover tbody tr:hover {
  background-color: rgba(111, 66, 193, 0.05);
}

/* Forms */
.form-control {
  border-radius: var(--border-radius);
  border: 1px solid #e3e6f0;
  transition: all 0.2s ease-in-out;
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 0.2rem rgba(111, 66, 193, 0.25);
}

.form-label {
  font-weight: 600;
  color: var(--dark);
  margin-bottom: 0.5rem;
}

.input-group-text {
  background-color: #f8f9fc;
  border-color: #e3e6f0;
  font-weight: 500;
}

/* Alerts */
.alert {
  border-radius: var(--border-radius);
  border: none;
  font-weight: 500;
}

.alert-primary {
  background-color: rgba(111, 66, 193, 0.1);
  color: var(--primary-dark);
}

.alert-success {
  background-color: rgba(25, 135, 84, 0.1);
  color: #0f5132;
}

.alert-info {
  background-color: rgba(13, 202, 240, 0.1);
  color: #055160;
}

.alert-warning {
  background-color: rgba(255, 193, 7, 0.1);
  color: #664d03;
}

.alert-danger {
  background-color: rgba(220, 53, 69, 0.1);
  color: #842029;
}

/* Badges */
.badge {
  font-weight: 500;
  border-radius: var(--border-radius);
}

/* Modal */
.modal-content {
  border: none;
  border-radius: var(--border-radius);
  box-shadow: var(--box-shadow-lg);
}

.modal-header {
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
  padding: 1.5rem;
}

.modal-body {
  padding: 1.5rem;
}

.modal-footer {
  border-top: 1px solid rgba(0, 0, 0, 0.05);
  padding: 1.5rem;
}

/* Progress bars */
.progress {
  border-radius: var(--border-radius);
  height: 0.75rem;
}

.progress-bar {
  border-radius: var(--border-radius);
}

/* Utilities */
.shadow-sm {
  box-shadow: var(--box-shadow) !important;
}

.shadow {
  box-shadow: var(--box-shadow-lg) !important;
}

.rounded {
  border-radius: var(--border-radius) !important;
}

.text-primary {
  color: var(--primary) !important;
}

.bg-primary {
  background-color: var(--primary) !important;
}

.border-primary {
  border-color: var(--primary) !important;
}

/* Mobile-First Off-Canvas Navigation */
.mobile-nav-toggle {
  width: var(--touch-target-md);
  height: var(--touch-target-md);
  border: none;
  background: transparent;
  color: currentColor;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--border-radius);
  transition: all 0.2s ease;
  z-index: var(--z-fixed);
}

@media (min-width: 992px) {
  .mobile-nav-toggle {
    display: none;
  }
}

.mobile-nav-toggle:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

.hamburger {
  width: 24px;
  height: 18px;
  position: relative;
  cursor: pointer;
}

.hamburger span {
  display: block;
  position: absolute;
  height: 2px;
  width: 100%;
  background: currentColor;
  border-radius: 1px;
  opacity: 1;
  left: 0;
  transform: rotate(0deg);
  transition: .25s ease-in-out;
}

.hamburger span:nth-child(1) {
  top: 0;
}

.hamburger span:nth-child(2) {
  top: 8px;
}

.hamburger span:nth-child(3) {
  top: 16px;
}

.hamburger.active span:nth-child(1) {
  top: 8px;
  transform: rotate(45deg);
}

.hamburger.active span:nth-child(2) {
  opacity: 0;
  left: -60px;
}

.hamburger.active span:nth-child(3) {
  top: 8px;
  transform: rotate(-45deg);
}

.offcanvas-nav {
  position: fixed;
  top: 0;
  left: -100%;
  width: var(--sidebar-width);
  height: 100vh;
  background: #ffffff;
  box-shadow: var(--box-shadow-xl);
  z-index: var(--z-modal);
  transition: left 0.3s ease-in-out;
  overflow-y: auto;
  padding-top: var(--navbar-height-mobile);
}

.offcanvas-nav.active {
  left: 0;
}

.offcanvas-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.5);
  z-index: var(--z-modal-backdrop);
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease-in-out;
}

.offcanvas-overlay.active {
  opacity: 1;
  visibility: visible;
}

.offcanvas-nav-header {
  padding: var(--spacing-lg);
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
}

.offcanvas-nav-body {
  padding: var(--spacing-md);
}

.offcanvas-nav-footer {
  padding: var(--spacing-lg);
  border-top: 1px solid rgba(0, 0, 0, 0.1);
  margin-top: auto;
}

/* Mobile Bottom Action Bar */
.bottom-action-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--bottom-action-bar-height);
  background: white;
  border-top: 1px solid rgba(0, 0, 0, 0.1);
  box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.1);
  z-index: var(--z-sticky);
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: var(--spacing-sm) var(--spacing-md);
}

@media (min-width: 992px) {
  .bottom-action-bar {
    display: none;
  }
}

.bottom-action-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: var(--touch-target-md);
  min-height: var(--touch-target-md);
  text-decoration: none;
  color: var(--secondary);
  font-size: var(--font-size-xs);
  font-weight: 500;
  border-radius: var(--border-radius);
  transition: all 0.2s ease;
  padding: var(--spacing-xs);
}

.bottom-action-item.active,
.bottom-action-item:hover {
  color: var(--primary);
  background-color: var(--primary-light);
}

.bottom-action-item svg {
  width: 20px;
  height: 20px;
  margin-bottom: var(--spacing-xs);
}

.bottom-action-item span {
  font-size: 10px;
  line-height: 1;
}

/* Mobile-First Responsive Utilities */
.mobile-only {
  display: block;
}

.desktop-only {
  display: none;
}

@media (min-width: 992px) {
  .mobile-only {
    display: none;
  }
  
  .desktop-only {
    display: block;
  }
}

.mobile-full-width {
  width: 100% !important;
}

@media (min-width: 768px) {
  .mobile-full-width {
    width: auto !important;
  }
}

.mobile-stack > * {
  width: 100% !important;
  margin-bottom: var(--spacing-sm) !important;
}

@media (min-width: 768px) {
  .mobile-stack {
    display: flex !important;
    gap: var(--spacing-sm) !important;
  }
  
  .mobile-stack > * {
    width: auto !important;
    margin-bottom: 0 !important;
  }
}

.mobile-centered {
  text-align: center;
}

@media (min-width: 768px) {
  .mobile-centered {
    text-align: left;
  }
}

/* Touch-Friendly Form Controls */
.form-control {
  min-height: var(--touch-target-md);
  padding: var(--spacing-sm) var(--spacing-md);
  font-size: var(--font-size-base);
  border-radius: var(--border-radius);
  border: 1px solid #e3e6f0;
  transition: all 0.2s ease-in-out;
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 0.2rem var(--primary-light);
}

.form-select {
  min-height: var(--touch-target-md);
  padding: var(--spacing-sm) var(--spacing-md);
  font-size: var(--font-size-base);
}

/* Responsive Content Padding */
.content-wrapper {
  padding: var(--mobile-padding);
  margin-bottom: var(--bottom-action-bar-height);
}

@media (min-width: 768px) {
  .content-wrapper {
    padding: var(--desktop-padding);
    margin-bottom: 0;
  }
}

@media (min-width: 992px) {
  .content-wrapper {
    margin-left: 0;
    padding-left: var(--desktop-padding);
    padding-right: var(--desktop-padding);
  }
}

/* Mobile-First Table Responsiveness */
@media (max-width: 768px) {
  .table-responsive {
    font-size: var(--font-size-sm);
    border: none;
  }
  
  .table-mobile-cards {
    display: block !important;
  }
  
  .table-mobile-cards thead {
    display: none;
  }
  
  .table-mobile-cards tbody,
  .table-mobile-cards tr,
  .table-mobile-cards td {
    display: block;
    width: 100%;
  }
  
  .table-mobile-cards tr {
    background: white;
    border-radius: var(--border-radius-lg);
    box-shadow: var(--box-shadow);
    margin-bottom: var(--spacing-md);
    padding: var(--spacing-md);
  }
  
  .table-mobile-cards td {
    border: none;
    padding: var(--spacing-xs) 0;
    text-align: left !important;
  }
  
  .table-mobile-cards td:before {
    content: attr(data-label) ": ";
    font-weight: 600;
    color: var(--secondary);
    text-transform: uppercase;
    font-size: var(--font-size-xs);
    letter-spacing: 0.05em;
  }
}

/* Footer */
footer {
  background-color: #f8f9fc !important;
  border-top: 1px solid rgba(0, 0, 0, 0.05);
}

/* Custom form styles */
.form-floating > .form-control {
  height: calc(3.5rem + 2px);
  line-height: 1.25;
}

.form-floating > label {
  padding: 1rem 0.75rem;
  font-size: 0.875rem;
  color: #6c757d;
}

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

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

.slide-up {
  animation: slideUp 0.3s ease-in-out;
}

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

/* Loading states */
.loading {
  position: relative;
  color: transparent !important;
  pointer-events: none;
}

.loading::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  top: 50%;
  left: 50%;
  margin-left: -8px;
  margin-top: -8px;
  border-radius: 50%;
  border: 2px solid #f3f3f3;
  border-top: 2px solid var(--primary);
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Enhanced Search Suggestions Styles */
.search-container {
  position: relative;
}

.search-suggestions-dropdown {
  background: white;
  border: 1px solid #dee2e6;
  border-radius: 0.5rem;
  box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
  animation: fadeInDown 0.2s ease-in-out;
  font-size: 0.875rem;
}

.suggestion-item {
  transition: all 0.2s ease-in-out;
  border-bottom: 1px solid #f1f3f4;
}

.suggestion-item:hover,
.suggestion-item.bg-light {
  background-color: #f8f9fa !important;
  transform: translateX(2px);
}

.suggestion-item:last-child {
  border-bottom: none;
}

.suggestion-title {
  font-size: 0.9rem;
  line-height: 1.3;
}

.suggestion-subtitle {
  font-size: 0.8rem;
  line-height: 1.2;
}

.search-footer {
  background-color: #f8f9fa;
  border-bottom-left-radius: 0.5rem;
  border-bottom-right-radius: 0.5rem;
  font-size: 0.75rem;
  color: #6c757d;
}

/* Search loading states */
.search-container .spinner-border-sm {
  width: 1rem;
  height: 1rem;
}

/* Search error states */
.search-error {
  background-color: #f8d7da;
  color: #721c24;
  border: 1px solid #f5c2c7;
}

/* Highlight matching text */
mark {
  background-color: #fff3cd;
  padding: 0.1rem 0.2rem;
  border-radius: 0.2rem;
  font-weight: 600;
}

@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Mobile Responsive Styles */
@media (max-width: 768px) {
  /* Adjust search container width for mobile */
  .search-container {
    width: 100% !important;
    max-width: 280px;
  }
  
  /* Hide entity type dropdown on smaller screens */
  .search-container select {
    display: none;
  }
  
  /* Adjust search input on mobile */
  .search-container .form-control {
    border-top-right-radius: 0.375rem !important;
    border-bottom-right-radius: 0.375rem !important;
  }
  
  /* Full width suggestions dropdown on mobile */
  .search-suggestions-dropdown {
    left: 0 !important;
    right: 0 !important;
    width: 100vw !important;
    max-width: 100vw !important;
    margin-left: -15px;
    margin-right: -15px;
    border-radius: 0;
    border-left: none;
    border-right: none;
    max-height: 60vh;
  }
  
  /* Adjust suggestion items for mobile */
  .suggestion-item {
    padding: 0.75rem 1rem;
  }
  
  .suggestion-title {
    font-size: 0.95rem;
  }
  
  .suggestion-subtitle {
    font-size: 0.8rem;
    margin-top: 0.25rem;
  }
  
  /* Stack suggestion content vertically on very small screens */
  @media (max-width: 480px) {
    .suggestion-item .d-flex {
      flex-direction: column;
      align-items: flex-start !important;
    }
    
    .suggestion-item .badge {
      margin-top: 0.5rem;
      align-self: flex-start;
    }
  }
}

@media (max-width: 576px) {
  /* Further adjustments for very small screens */
  .search-container {
    margin: 0.5rem !important;
    max-width: none;
  }
  
  /* Collapse navbar search on very small screens */
  .navbar .search-container {
    order: 3;
    width: 100%;
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
  }
}

/* Accessibility improvements */
.search-suggestions-dropdown:focus-within {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.suggestion-item:focus {
  outline: 2px solid var(--primary);
  outline-offset: -2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .search-suggestions-dropdown {
    border: 2px solid #000;
  }
  
  .suggestion-item:hover,
  .suggestion-item.bg-light {
    background-color: #000 !important;
    color: #fff !important;
  }
}