// Content Boxes

// Variables

$widget-spacer: $spacer;

.widget-content {
  display: flex;
  padding: $widget-spacer;
  flex-direction: row;
  align-items: center;

  .widget-content-wrapper {
    display: flex;
    flex: 1;
    position: relative;
    align-items: center;
  }

  .widget-content-left {
    .widget-heading {
      opacity: 0.8;
      font-weight: bold;
    }

    .widget-subheading {
      opacity: 0.5;
    }
  }

  .widget-content-right {
    margin-left: auto;
  }

  .widget-numbers {
    font-weight: bold;
    font-size: 1.8rem;
    display: block;
  }

  .widget-content-outer {
    display: flex;
    flex: 1;
    flex-direction: column;
  }

  .widget-progress-wrapper {
    margin-top: $widget-spacer;

    .progress-sub-label {
      margin-top: ($widget-spacer / 3);
      opacity: 0.5;
      display: flex;
      align-content: center;
      align-items: center;

      .sub-label-left {
      }

      .sub-label-right {
        margin-left: auto;
      }
    }
  }

  .widget-content-right {
    &.widget-content-actions {
      visibility: hidden;
      opacity: 0;
      transition: opacity 0.2s;
    }
  }

  &:hover {
    .widget-content-right {
      &.widget-content-actions {
        visibility: visible;
        opacity: 1;
      }
    }
  }
}

// ======================================
// BOOTSTRAP 5 PROGRESS COMPONENT - COMPLETE IMPLEMENTATION
// ======================================

// Bootstrap 5 Progress base component with CSS custom properties + fallbacks
.progress,
.progress-stacked {
  --bs-progress-height: 1rem;
  --bs-progress-font-size: 0.75rem;
  --bs-progress-bg: #e9ecef;
  --bs-progress-border-radius: 0.375rem;
  --bs-progress-box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.075);
  --bs-progress-bar-color: #fff;
  --bs-progress-bar-bg: #0d6efd;
  --bs-progress-bar-transition: width 0.6s ease;

  display: flex !important;
  height: 1rem; // Fallback
  height: var(--bs-progress-height);
  overflow: hidden;
  font-size: 0.75rem; // Fallback
  font-size: var(--bs-progress-font-size);
  background-color: #e9ecef !important; // Fallback
  background-color: var(--bs-progress-bg) !important;
  border-radius: 0.375rem;
  border-radius: var(--bs-progress-border-radius);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.075);
  box-shadow: var(--bs-progress-box-shadow);
}

.progress-bar {
  display: flex !important;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  color: #fff; // Fallback
  color: var(--bs-progress-bar-color);
  text-align: center;
  white-space: nowrap;
  background-color: #007bff !important; // Fallback
  background-color: var(--bs-progress-bar-bg) !important;
  transition: width 0.6s ease;
  transition: var(--bs-progress-bar-transition);

  // Ensure the progress bar actually shows
  min-height: 100%;
  min-width: 0;
}

// Custom progress bar height variants for ArchitectUI
.progress.progress-bar-xs,
.progress-bar-xs {
  --bs-progress-height: 4px !important;
  height: 4px !important;
  height: var(--bs-progress-height) !important;
}

.progress.progress-bar-sm,
.progress-bar-sm {
  --bs-progress-height: 6px !important;
  height: 6px !important;
  height: var(--bs-progress-height) !important;
}

.progress.progress-bar-lg,
.progress-bar-lg {
  --bs-progress-height: 10px !important;
  height: 10px !important;
  height: var(--bs-progress-height) !important;
}

// Progress bar color variants with fallbacks
.progress-bar.bg-primary {
  --bs-progress-bar-bg: #007bff !important;
  background-color: #007bff !important;
}

.progress-bar.bg-success {
  --bs-progress-bar-bg: #28a745 !important;
  background-color: #28a745 !important;
}

.progress-bar.bg-warning {
  --bs-progress-bar-bg: #ffc107 !important;
  --bs-progress-bar-color: #212529 !important;
  background-color: #ffc107 !important;
  color: #212529 !important;
}

.progress-bar.bg-danger {
  --bs-progress-bar-bg: #dc3545 !important;
  background-color: #dc3545 !important;
}

.progress-bar.bg-info {
  --bs-progress-bar-bg: #17a2b8 !important;
  background-color: #17a2b8 !important;
}

// Additional theme color support
.progress-bar.bg-secondary {
  --bs-progress-bar-bg: #6c757d !important;
  background-color: #6c757d !important;
}

.progress-bar.bg-dark {
  --bs-progress-bar-bg: #343a40 !important;
  background-color: #343a40 !important;
}

.progress-bar.bg-light {
  --bs-progress-bar-bg: #f8f9fa !important;
  --bs-progress-bar-color: #495057 !important;
  background-color: #f8f9fa !important;
  color: #495057 !important;
}

// Enhanced progress animations
.progress-bar-animated {
  animation: progress-bar-stripes 1s linear infinite;
}

.progress-bar-animated-alt {
  animation: progress-bar-stripes 1s linear infinite reverse;
}

.progress-bar-striped {
  background-image: linear-gradient(
    45deg,
    rgba(255, 255, 255, 0.15) 25%,
    transparent 25%,
    transparent 50%,
    rgba(255, 255, 255, 0.15) 50%,
    rgba(255, 255, 255, 0.15) 75%,
    transparent 75%,
    transparent
  );
  background-size: var(--bs-progress-height) var(--bs-progress-height);
}

@keyframes progress-bar-stripes {
  0% {
    background-position-x: var(--bs-progress-height);
  }
}

// Progress wrapper responsive improvements
@media (max-width: 768px) {
  .widget-progress-wrapper {
    margin-top: ($widget-spacer / 2);

    .progress-sub-label {
      flex-direction: column;
      text-align: center;

      .sub-label-left,
      .sub-label-right {
        margin: 0.25rem 0;
      }
    }
  }
}

// ======================================
// BOOTSTRAP 5 UTILITY CLASS FIXES
// ======================================

// Ensure Bootstrap 5 margin/padding utilities work properly
.ms-0 {
  margin-left: 0 !important;
}
.me-3 {
  margin-right: 1rem !important;
}
.mb-3 {
  margin-bottom: 1rem !important;
}
.mt-4 {
  margin-top: 1.5rem !important;
}
.mt-5 {
  margin-top: 3rem !important;
}
.p-0 {
  padding: 0 !important;
}
.p-2 {
  padding: 0.5rem !important;
}
.pt-0 {
  padding-top: 0 !important;
}
.pb-0 {
  padding-bottom: 0 !important;
}

// Bootstrap 5 Grid utilities
.g-0 {
  --bs-gutter-x: 0;
  --bs-gutter-y: 0;
}
.row.g-0 > * {
  padding-right: calc(var(--bs-gutter-x) * 0.5);
  padding-left: calc(var(--bs-gutter-x) * 0.5);
  margin-top: calc(var(--bs-gutter-y) * 0.5);
}

// Bootstrap 5 text utilities
.text-white {
  color: #fff !important;
}
.text-dark {
  color: #212529 !important;
}
.text-success {
  color: #198754 !important;
}
.text-primary {
  color: #007bff !important;
}
.text-warning {
  color: #ffc107 !important;
}
.text-danger {
  color: #dc3545 !important;
}

// Widget specific fixes
.widget-content-wrapper {
  width: 100% !important;
}

.widget-numbers {
  white-space: nowrap;
  line-height: 1;
}

.widget-heading {
  font-size: 1rem;
  line-height: 1.2;
  margin-bottom: 0.25rem;
}

.widget-subheading {
  font-size: 0.875rem;
  line-height: 1.2;
}

// ======================================
// BOOTSTRAP 5 LIST GROUP FIXES
// ======================================

// Ensure list-group components work properly
.list-group {
  display: flex;
  flex-direction: column;
  padding-left: 0;
  margin-bottom: 0;
  border-radius: 0.375rem;
}

.list-group-item {
  position: relative;
  display: block;
  padding: 0.5rem 1rem;
  color: #212529;
  text-decoration: none;
  background-color: #fff;
  border: 1px solid rgba(0, 0, 0, 0.125);
}

.list-group-item:first-child {
  border-top-left-radius: inherit;
  border-top-right-radius: inherit;
}

.list-group-item:last-child {
  border-bottom-right-radius: inherit;
  border-bottom-left-radius: inherit;
}

.list-group-item:not(:first-child) {
  border-top-width: 0;
}

.list-group-flush {
  border-radius: 0;
}

.list-group-flush > .list-group-item {
  border-width: 0 0 1px;
  border-radius: 0;
}

.list-group-flush > .list-group-item:last-child {
  border-bottom-width: 0;
}

// ======================================
// CARD COMPONENT FIXES
// ======================================

// Ensure card components display properly
.card {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  word-wrap: break-word;
  background-color: #fff;
  background-clip: border-box;
  border: 1px solid rgba(0, 0, 0, 0.125);
  border-radius: 0.375rem;
}

.card-body {
  flex: 1 1 auto;
  padding: 1rem;
}

// Fix for main-card class
.main-card {
  @extend .card;
}
