/**
 * ============================================
 * MSI STUDIO DESIGN SYSTEM - BOOTSTRAP COMPONENTS
 * ============================================
 *
 * Componentes adicionales inspirados en Bootstrap adaptados
 * al design system de MSI Studio:
 * - Breadcrumbs
 * - Pagination
 * - Progress Bars
 * - Spinners/Loaders
 * - Tooltips
 * - Popovers
 * - Dropdowns
 * - Accordion
 * - List Groups
 * - Navbar Extras
 * - Toast Notifications
 * - Offcanvas
 *
 * Debe importarse después de components.css
 */

/* ============================================
   BREADCRUMBS
   ============================================ */

.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--spacing-8);
  padding: var(--spacing-12) 0;
  margin-bottom: var(--spacing-16);
  list-style: none;
  font-size: var(--font-size-body-sm);
  color: var(--text-secondary);
}

.breadcrumb-item {
  display: inline-flex;
  align-items: center;
  gap: var(--spacing-8);
}

.breadcrumb-item a {
  color: var(--text-accent);
  text-decoration: none;
  transition: color 0.3s ease;
}

.breadcrumb-item a:hover {
  color: var(--text-accent-hover);
}

.breadcrumb-item.active {
  color: var(--text-primary);
  font-weight: var(--font-weight-demi-bold);
}

.breadcrumb-item + .breadcrumb-item::before {
  content: "/";
  color: var(--text-tertiary);
  padding: 0 var(--spacing-4);
}

/* Alternative Separator */
.breadcrumb-item.arrow + .breadcrumb-item::before {
  content: "→";
}

.breadcrumb-item.chevron + .breadcrumb-item::before {
  content: "›";
}

/* ============================================
   PAGINATION
   ============================================ */

.pagination {
  display: flex;
  align-items: center;
  gap: var(--spacing-4);
  padding: 0;
  margin: var(--spacing-24) 0;
  list-style: none;
}

.page-item {
  display: inline-flex;
}

.page-link {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 2.5rem;
  height: 2.5rem;
  padding: var(--spacing-8) var(--spacing-12);
  font-size: var(--font-size-body-sm);
  font-weight: var(--font-weight-demi-bold);
  color: var(--text-primary);
  text-decoration: none;
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-md);
  background-color: var(--bg-primary);
  transition: all 0.3s ease;
  cursor: pointer;
}

.page-link:hover:not(.disabled) {
  background-color: var(--bg-accent);
  color: var(--text-primary-invert);
  border-color: var(--bg-accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.page-item.active .page-link {
  background-color: var(--bg-accent);
  color: var(--text-primary-invert);
  border-color: var(--bg-accent);
  cursor: default;
}

.page-item.disabled .page-link {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* Pagination Sizes */
.pagination-sm .page-link {
  min-width: 2rem;
  height: 2rem;
  padding: var(--spacing-4) var(--spacing-8);
  font-size: var(--font-size-caption);
}

.pagination-lg .page-link {
  min-width: 3rem;
  height: 3rem;
  padding: var(--spacing-12) var(--spacing-16);
  font-size: var(--font-size-body-md);
}

/* ============================================
   PROGRESS BARS
   ============================================ */

.progress {
  display: flex;
  height: 1rem;
  overflow: hidden;
  background-color: var(--bg-tertiary);
  border-radius: var(--radius-full);
  box-shadow: inset 0 1px 2px rgb(0 0 0 / 0.1);
}

.progress-bar {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  color: var(--text-primary-invert);
  text-align: center;
  white-space: nowrap;
  background-color: var(--bg-accent);
  transition: width 0.6s ease;
  font-size: var(--font-size-caption);
  font-weight: var(--font-weight-bold);
}

/* Progress Bar Colors */
.progress-bar-success {
  background-color: var(--success-green);
}

.progress-bar-warning {
  background-color: var(--alert-yellow);
  color: var(--text-primary);
}

.progress-bar-error,
.progress-bar-danger {
  background-color: var(--error-red);
}

.progress-bar-info {
  background-color: var(--turquoise-500);
}

/* Striped Progress */
.progress-bar-striped {
  background-image: linear-gradient(
    45deg,
    rgb(255 255 255 / 0.15) 25%,
    transparent 25%,
    transparent 50%,
    rgb(255 255 255 / 0.15) 50%,
    rgb(255 255 255 / 0.15) 75%,
    transparent 75%,
    transparent
  );
  background-size: 1rem 1rem;
}

/* Animated Progress */
.progress-bar-animated {
  animation: progress-bar-stripes 1s linear infinite;
}

@keyframes progress-bar-stripes {
  0% {
    background-position: 1rem 0;
  }
  100% {
    background-position: 0 0;
  }
}

/* Progress Sizes */
.progress-sm {
  height: 0.5rem;
}

.progress-lg {
  height: 1.5rem;
}

.progress-xl {
  height: 2rem;
}

/* ============================================
   SPINNERS / LOADERS
   ============================================ */

.spinner {
  display: inline-block;
  width: 2rem;
  height: 2rem;
  vertical-align: text-bottom;
  border: 0.25rem solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spinner-rotate 0.75s linear infinite;
}

@keyframes spinner-rotate {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

/* Spinner Sizes */
.spinner-sm {
  width: 1rem;
  height: 1rem;
  border-width: 0.15rem;
}

.spinner-lg {
  width: 3rem;
  height: 3rem;
  border-width: 0.35rem;
}

.spinner-xl {
  width: 4rem;
  height: 4rem;
  border-width: 0.5rem;
}

/* Spinner Colors */
.spinner-primary {
  color: var(--bg-accent);
}

.spinner-success {
  color: var(--success-green);
}

.spinner-warning {
  color: var(--alert-yellow);
}

.spinner-error,
.spinner-danger {
  color: var(--error-red);
}

/* Growing Spinner */
.spinner-grow {
  display: inline-block;
  width: 2rem;
  height: 2rem;
  vertical-align: text-bottom;
  background-color: currentColor;
  border-radius: 50%;
  opacity: 0;
  animation: spinner-grow 0.75s linear infinite;
}

@keyframes spinner-grow {
  0% {
    transform: scale(0);
    opacity: 0;
  }
  50% {
    opacity: 1;
  }
  100% {
    transform: scale(1);
    opacity: 0;
  }
}

/* ============================================
   TOOLTIPS
   ============================================ */

.tooltip {
  position: absolute;
  z-index: 1070;
  display: block;
  margin: 0;
  font-size: var(--font-size-body-sm);
  font-weight: var(--font-weight-regular);
  line-height: var(--line-height-body-sm);
  text-align: start;
  text-decoration: none;
  text-shadow: none;
  text-transform: none;
  letter-spacing: normal;
  word-break: normal;
  word-spacing: normal;
  white-space: normal;
  line-break: auto;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.tooltip.show {
  opacity: 1;
}

.tooltip-inner {
  max-width: 200px;
  padding: var(--spacing-8) var(--spacing-12);
  color: var(--text-primary-invert);
  text-align: center;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
}

/* Tooltip Arrow */
.tooltip-arrow {
  position: absolute;
  display: block;
  width: 0.8rem;
  height: 0.4rem;
}

.tooltip-arrow::before {
  position: absolute;
  content: "";
  border-color: transparent;
  border-style: solid;
}

/* Tooltip Placements */
.tooltip-top {
  padding-bottom: 0.4rem;
}

.tooltip-top .tooltip-arrow {
  bottom: 0;
}

.tooltip-top .tooltip-arrow::before {
  top: 0;
  /* stylelint-disable-next-line declaration-property-value-allowed-list */
  border-width: 0.4rem 0.4rem 0;
  border-top-color: var(--neutral-900);
}

.tooltip-bottom {
  padding-top: 0.4rem;
}

.tooltip-bottom .tooltip-arrow {
  top: 0;
}

.tooltip-bottom .tooltip-arrow::before {
  bottom: 0;
  border-width: 0 0.4rem 0.4rem;
  border-bottom-color: var(--neutral-900);
}

.tooltip-left {
  padding-right: 0.4rem;
}

.tooltip-left .tooltip-arrow {
  right: 0;
  width: 0.4rem;
  height: 0.8rem;
}

.tooltip-left .tooltip-arrow::before {
  left: 0;
  border-width: 0.4rem 0 0.4rem 0.4rem;
  border-left-color: var(--neutral-900);
}

.tooltip-right {
  padding-left: 0.4rem;
}

.tooltip-right .tooltip-arrow {
  left: 0;
  width: 0.4rem;
  height: 0.8rem;
}

.tooltip-right .tooltip-arrow::before {
  right: 0;
  /* stylelint-disable-next-line declaration-property-value-allowed-list */
  border-width: 0.4rem 0.4rem 0.4rem 0;
  border-right-color: var(--neutral-900);
}

/* ============================================
   DROPDOWNS
   ============================================ */

.dropdown {
  position: relative;
  display: inline-flex;
}

.dropdown-toggle {
  display: inline-flex;
  align-items: center;
  gap: var(--spacing-8);
}

.dropdown-toggle::after {
  content: "";
  display: inline-block;
  margin-left: var(--spacing-4);
  vertical-align: middle;
  border-top: 0.3em solid;
  border-right: 0.3em solid transparent;
  border-bottom: 0;
  border-left: 0.3em solid transparent;
}

.dropdown-menu {
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 1000;
  display: none;
  min-width: 10rem;
  padding: var(--spacing-8) 0;
  margin: var(--spacing-4) 0 0;
  font-size: var(--font-size-body-sm);
  color: var(--text-primary);
  text-align: left;
  list-style: none;
  background-color: var(--bg-primary);
  background-clip: padding-box;
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
}

.dropdown-menu.show {
  display: block;
}

.dropdown-menu-right {
  right: 0;
  left: auto;
}

.dropdown-item {
  display: block;
  width: 100%;
  padding: var(--spacing-8) var(--spacing-16);
  clear: both;
  font-weight: var(--font-weight-regular);
  color: var(--text-primary);
  text-align: inherit;
  text-decoration: none;
  white-space: nowrap;
  background-color: transparent;
  border: 0;
  cursor: pointer;
  transition: all 0.3s ease;
}

.dropdown-item:hover,
.dropdown-item:focus {
  color: var(--text-primary);
  background-color: var(--bg-tertiary);
}

.dropdown-item.active {
    color: var(--text-primary);
    background-color: var(--bg-tertiary);
}

.dropdown-item:disabled,
.dropdown-item.disabled {
  color: var(--text-tertiary);
  pointer-events: none;
  background-color: transparent;
  opacity: 0.5;
}

.dropdown-divider {
  height: 0;
  margin: var(--spacing-8) 0;
  overflow: hidden;
  border-top: 1px solid var(--border-primary);
}

.dropdown-header {
  display: block;
  padding: var(--spacing-8) var(--spacing-16);
  margin-bottom: 0;
  font-size: var(--font-size-caption);
  font-weight: var(--font-weight-bold);
  color: var(--text-tertiary);
  text-transform: uppercase;
  white-space: nowrap;
}

/* ============================================
   ACCORDION
   ============================================ */

.accordion {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-8);
}

.accordion-item {
  background-color: var(--bg-primary);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.accordion-header {
  margin-bottom: 0;
}

.accordion-button {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
  padding: var(--spacing-16) var(--spacing-24);
  font-size: var(--font-size-body-sm);
  font-weight: var(--font-weight-demi-bold);
  color: var(--text-primary);
  text-align: left;
  background-color: transparent;
  border: 0;
  border-radius: 0;
  overflow-anchor: none;
  transition: all 0.3s ease;
  cursor: pointer;
}

.accordion-button:hover {
  background-color: var(--bg-secondary);
}

.accordion-button:not(.collapsed) {
  color: var(--text-accent);
  background-color: var(--bg-secondary);
}

.accordion-button::after {
  content: "";
  flex-shrink: 0;
  width: 1.25rem;
  height: 1.25rem;
  margin-left: auto;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%230f172a'%3e%3cpath fill-rule='evenodd' d='M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708z'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-size: 1.25rem;
  transition: transform 0.3s ease;
}

[data-bs-theme="dark"] .accordion-button::after {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23eee9e0'%3e%3cpath fill-rule='evenodd' d='M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708z'/%3e%3c/svg%3e");
}

.accordion-button:not(.collapsed)::after {
  transform: rotate(-180deg);
}

.accordion-collapse {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
}

.accordion-collapse.show {
  max-height: 1000px;
}

.accordion-body {
  padding: var(--spacing-16) var(--spacing-24);
  color: var(--text-secondary);
  border-top: 1px solid var(--border-primary);
}

/* Flush Accordion (no borders) */
.accordion-flush .accordion-item {
  border: 0;
  border-radius: 0;
  border-bottom: 1px solid var(--border-primary);
}

.accordion-flush .accordion-item:last-child {
  border-bottom: 0;
}

/* ============================================
   LIST GROUPS
   ============================================ */

.list-group {
  display: flex;
  flex-direction: column;
  padding-left: 0;
  margin-bottom: 0;
  border-radius: var(--radius-md);
}

.list-group-item {
  position: relative;
  display: block;
  padding: var(--spacing-12) var(--spacing-16);
  color: var(--text-primary);
  text-decoration: none;
  background-color: var(--bg-primary);
  border: 1px solid var(--border-primary);
  transition: all 0.3s ease;
}

.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 + .list-group-item {
  border-top-width: 0;
}

.list-group-item:hover {
  background-color: var(--bg-secondary);
  border-color: var(--border-secondary);
}

.list-group-item.active {
  z-index: 2;
  color: var(--text-primary-invert);
  background-color: var(--bg-accent);
  border-color: var(--bg-accent);
}

.list-group-item.disabled,
.list-group-item:disabled {
  color: var(--text-tertiary);
  pointer-events: none;
  background-color: var(--bg-disabled);
  opacity: 0.5;
}

/* List Group Variants */
.list-group-item-primary {
  color: var(--blue-900);
  background-color: var(--blue-100);
}

.list-group-item-success {
  color: var(--success-green-dark);
  background-color: var(--success-green-light);
}

.list-group-item-warning {
  color: var(--alert-yellow-dark);
  background-color: var(--alert-yellow-light);
}

.list-group-item-danger,
.list-group-item-error {
  color: var(--error-red-dark);
  background-color: var(--error-red-light);
}

/* Flush List Group */
.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;
}

/* Horizontal List Group */
.list-group-horizontal {
  flex-direction: row;
}

.list-group-horizontal .list-group-item {
  border-right-width: 0;
  border-bottom-width: 1px;
}

.list-group-horizontal .list-group-item:first-child {
  border-bottom-left-radius: inherit;
  border-top-right-radius: 0;
}

.list-group-horizontal .list-group-item:last-child {
  border-top-right-radius: inherit;
  border-bottom-left-radius: 0;
  border-right-width: 1px;
}

.list-group-horizontal .list-group-item + .list-group-item {
  border-top-width: 1px;
  border-left-width: 1px;
}

/* ============================================
   TOAST NOTIFICATIONS
   ============================================ */

.toast-container {
  position: fixed;
  z-index: 1090;
  display: flex;
  flex-direction: column;
  gap: var(--spacing-12);
  padding: var(--spacing-16);
  pointer-events: none;
}

.toast-container.top-right {
  top: 0;
  right: 0;
}

.toast-container.top-left {
  top: 0;
  left: 0;
}

.toast-container.bottom-right {
  bottom: 0;
  right: 0;
}

.toast-container.bottom-left {
  bottom: 0;
  left: 0;
}

.toast-container.top-center {
  top: 0;
  left: 50%;
  transform: translateX(-50%);
}

.toast {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 250px;
  max-width: 350px;
  font-size: var(--font-size-body-sm);
  pointer-events: auto;
  background-color: var(--bg-primary);
  background-clip: padding-box;
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xl);
  opacity: 0;
  transform: translateY(-1rem);
  transition: all 0.3s ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast-header {
  display: flex;
  align-items: center;
  padding: var(--spacing-12) var(--spacing-16);
  color: var(--text-primary);
  background-color: var(--bg-secondary);
  background-clip: padding-box;
  border-bottom: 1px solid var(--border-primary);
  border-top-left-radius: calc(var(--radius-md) - 1px);
  border-top-right-radius: calc(var(--radius-md) - 1px);
}

.toast-title {
  margin-right: auto;
  font-weight: var(--font-weight-demi-bold);
}

.toast-close {
  margin-left: var(--spacing-8);
  padding: var(--spacing-4);
  background: transparent;
  border: 0;
  cursor: pointer;
  opacity: 0.5;
  transition: opacity 0.3s ease;
}

.toast-close:hover {
  opacity: 1;
}

.toast-body {
  padding: var(--spacing-16);
  color: var(--text-secondary);
}

/* Toast Variants */
.toast-success .toast-header {
  background-color: var(--success-green);
  color: var(--text-primary-invert);
  border-bottom-color: var(--success-green-dark);
}

.toast-warning .toast-header {
  background-color: var(--alert-yellow);
  color: var(--text-primary);
  border-bottom-color: var(--alert-yellow-dark);
}

.toast-error .toast-header,
.toast-danger .toast-header {
  background-color: var(--error-red);
  color: var(--text-primary-invert);
  border-bottom-color: var(--error-red-dark);
}

.toast-info .toast-header {
  background-color: var(--blue-500);
  color: var(--text-primary-invert);
  border-bottom-color: var(--blue-600);
}

/* ============================================
   OFFCANVAS
   ============================================ */

.offcanvas {
  position: fixed;
  bottom: 0;
  z-index: 1050;
  display: flex;
  flex-direction: column;
  max-width: 100%;
  visibility: hidden;
  background-color: var(--bg-primary);
  background-clip: padding-box;
  outline: 0;
  transition: transform 0.3s ease-in-out;
  box-shadow: var(--shadow-2xl);
}

.offcanvas.show {
  visibility: visible;
}

/* Offcanvas Start (Left) */
.offcanvas-start {
  top: 0;
  left: 0;
  width: 400px;
  border-right: 1px solid var(--border-primary);
  transform: translateX(-100%);
}

.offcanvas-start.show {
  transform: translateX(0);
}

/* Offcanvas End (Right) */
.offcanvas-end {
  top: 0;
  right: 0;
  width: 400px;
  border-left: 1px solid var(--border-primary);
  transform: translateX(100%);
}

.offcanvas-end.show {
  transform: translateX(0);
}

/* Offcanvas Top */
.offcanvas-top {
  top: 0;
  right: 0;
  left: 0;
  height: 30vh;
  max-height: 100%;
  border-bottom: 1px solid var(--border-primary);
  transform: translateY(-100%);
}

.offcanvas-top.show {
  transform: translateY(0);
}

/* Offcanvas Bottom */
.offcanvas-bottom {
  right: 0;
  left: 0;
  height: 30vh;
  max-height: 100%;
  border-top: 1px solid var(--border-primary);
  transform: translateY(100%);
}

.offcanvas-bottom.show {
  transform: translateY(0);
}

.offcanvas-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--spacing-24);
  border-bottom: 1px solid var(--border-primary);
}

.offcanvas-title {
  margin-bottom: 0;
  font-size: var(--font-size-heading-lg);
  font-weight: var(--font-weight-bold);
  line-height: var(--line-height-heading-lg);
}

.offcanvas-body {
  flex-grow: 1;
  padding: var(--spacing-24);
  overflow-y: auto;
}

/* Offcanvas Backdrop */
.offcanvas-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1040;
  width: 100vw;
  height: 100vh;
  background-color: var(--backdrop-overlay);
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

.offcanvas-backdrop.show {
  opacity: 1;
  pointer-events: auto;
}

/* ============================================
   CLOSE BUTTON (Utility)
   ============================================ */

.btn-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  padding: 0;
  color: var(--text-primary);
  background: transparent url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%230f172a'%3e%3cpath d='M.293.293a1 1 0 011.414 0L8 6.586 14.293.293a1 1 0 111.414 1.414L9.414 8l6.293 6.293a1 1 0 01-1.414 1.414L8 9.414l-6.293 6.293a1 1 0 01-1.414-1.414L6.586 8 .293 1.707a1 1 0 010-1.414z'/%3e%3c/svg%3e") center/1em auto no-repeat;
  border: 0;
  border-radius: var(--radius-sm);
  opacity: 0.5;
  cursor: pointer;
  transition: opacity 0.3s ease;
}

.btn-close:hover {
  opacity: 1;
}

[data-bs-theme="dark"] .btn-close {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23eee9e0'%3e%3cpath d='M.293.293a1 1 0 011.414 0L8 6.586 14.293.293a1 1 0 111.414 1.414L9.414 8l6.293 6.293a1 1 0 01-1.414 1.414L8 9.414l-6.293 6.293a1 1 0 01-1.414-1.414L6.586 8 .293 1.707a1 1 0 010-1.414z'/%3e%3c/svg%3e");
}

/* ============================================
   DIVIDER
   ============================================ */

.divider {
  height: 1px;
  background-color: var(--border-primary);
  border: 0;
  margin: var(--spacing-16) 0;
}

.divider-vertical {
  display: inline-block;
  width: 1px;
  height: 1.5rem;
  background-color: var(--border-primary);
  vertical-align: middle;
  margin: 0 var(--spacing-8);
}
