/*
 * Design system: bibliotecas de terceiros.
 * SweetAlert2, notifIt, bootstrap-select, jQuery UI, emojionearea, tag-it,
 * Swiper, Highcharts e players (mediaelement, plyr, video.js).
 */

/* ---------- SweetAlert2 ---------- */

.swal2-container.swal2-shown {
  background-color: var(--overlay) !important;
}

.swal2-modal,
.swal2-popup {
  padding: var(--space-6) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--radius-xl) !important;
  background: var(--popover) !important;
  color: var(--popover-foreground) !important;
  box-shadow: var(--shadow-lg) !important;
  font-family: var(--font-sans) !important;
}

.swal2-modal h2,
.swal2-title {
  margin: 0 0 var(--space-2) !important;
  color: var(--foreground) !important;
  font-size: var(--text-xl) !important;
  font-weight: 600 !important;
  line-height: 1.3 !important;
}

.swal2-content {
  color: var(--muted-foreground) !important;
  font-size: var(--text-base) !important;
  line-height: var(--leading-normal) !important;
}

.swal2-buttonswrapper,
.swal2-actions {
  display: flex !important;
  justify-content: flex-end !important;
  gap: var(--space-2);
  margin-top: var(--space-6) !important;
}

.swal2-styled {
  min-height: 36px;
  margin: 0 !important;
  padding: 0 var(--space-4) !important;
  border-radius: var(--radius-md) !important;
  font-size: var(--text-base) !important;
  font-weight: 500 !important;
  box-shadow: none !important;
}

.swal2-styled.swal2-confirm {
  order: 2;
  background-color: var(--primary) !important;
  color: var(--primary-foreground) !important;
}

.swal2-styled.swal2-cancel {
  order: 1;
  border: 1px solid var(--input) !important;
  background-color: var(--background) !important;
  color: var(--foreground) !important;
}

.swal2-styled:focus {
  box-shadow: var(--focus-ring) !important;
}

.swal2-input,
.swal2-textarea,
.swal2-select {
  border: 1px solid var(--input) !important;
  border-radius: var(--radius-md) !important;
  background: transparent !important;
  color: var(--foreground) !important;
  box-shadow: none !important;
}

.swal2-icon {
  transform: scale(.7);
  margin: 0 auto var(--space-2) !important;
}

/* ---------- notifIt (toasts) ---------- */

#ui_notifIt {
  z-index: var(--z-toast) !important;
  top: auto !important;
  bottom: var(--space-6) !important;
  left: 50% !important;
  right: auto !important;
  width: auto !important;
  min-width: 280px;
  max-width: calc(100vw - 32px);
  height: auto !important;
  padding: var(--space-3) var(--space-4) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--radius-lg) !important;
  background: var(--popover) !important;
  color: var(--popover-foreground) !important;
  box-shadow: var(--shadow-lg) !important;
  transform: translateX(-50%);
  opacity: 1 !important;
}

#ui_notifIt p {
  margin: 0 !important;
  color: var(--popover-foreground) !important;
  font-size: var(--text-base) !important;
  font-weight: 500 !important;
  line-height: 1.5 !important;
  text-align: left !important;
}

#ui_notifIt.success { border-left: 3px solid var(--success) !important; }
#ui_notifIt.error { border-left: 3px solid var(--destructive) !important; }
#ui_notifIt.warning { border-left: 3px solid var(--warning) !important; }
#ui_notifIt.info { border-left: 3px solid var(--brand) !important; }

@media (max-width: 767px) {
  #ui_notifIt {
    bottom: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom) + 12px) !important;
  }
}

/* ---------- Snackbar legado ---------- */

#snackbar,
.snackbar {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg) !important;
  background: var(--popover) !important;
  color: var(--popover-foreground) !important;
  box-shadow: var(--shadow-lg) !important;
}

/* ---------- bootstrap-select ---------- */

.bootstrap-select > .dropdown-toggle,
.bootstrap-select .btn.dropdown-toggle {
  height: 40px;
  padding: 0 var(--space-3) !important;
  border: 1px solid var(--input) !important;
  border-radius: var(--radius-md) !important;
  background: transparent !important;
  color: var(--foreground) !important;
  font-weight: 400;
  box-shadow: var(--shadow-xs) !important;
}

.bootstrap-select > .dropdown-toggle:hover {
  background: var(--accent) !important;
}

.bootstrap-select.open > .dropdown-toggle,
.bootstrap-select > .dropdown-toggle:focus {
  border-color: var(--ring) !important;
  box-shadow: 0 0 0 3px color-mix(in oklch, var(--ring) 25%, transparent) !important;
  outline: none !important;
}

.bootstrap-select > .dropdown-toggle .filter-option {
  display: flex;
  align-items: center;
}

.bootstrap-select > .dropdown-toggle.bs-placeholder,
.bootstrap-select > .dropdown-toggle.bs-placeholder:hover {
  color: var(--muted-foreground) !important;
}

.bootstrap-select .caret {
  border-top-color: var(--muted-foreground);
}

.bootstrap-select .dropdown-menu {
  padding: var(--space-1) !important;
}

.bootstrap-select .dropdown-menu li a {
  padding: var(--space-2) !important;
  border-radius: var(--radius-sm);
  color: var(--popover-foreground) !important;
}

.bootstrap-select .dropdown-menu li.selected a,
.bootstrap-select .dropdown-menu li.active a {
  background: var(--accent) !important;
  color: var(--accent-foreground) !important;
  font-weight: 500;
}

.bootstrap-select .dropdown-menu li a span.check-mark {
  color: var(--foreground);
}

.bootstrap-select .bs-searchbox .form-control {
  height: 36px;
}

.bootstrap-select.show-menu-arrow .dropdown-toggle:before,
.bootstrap-select.show-menu-arrow .dropdown-toggle:after {
  display: none !important;
}

/* ---------- jQuery UI ---------- */

.ui-widget {
  font-family: var(--font-sans) !important;
}

.ui-widget-content,
.ui-autocomplete,
.ui-datepicker {
  z-index: var(--z-toast) !important;
  padding: var(--space-1) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--radius-lg) !important;
  background: var(--popover) !important;
  color: var(--popover-foreground) !important;
  box-shadow: var(--shadow-lg) !important;
}

.ui-menu .ui-menu-item,
.ui-menu .ui-menu-item-wrapper {
  padding: var(--space-2) !important;
  border: 0 !important;
  border-radius: var(--radius-sm);
  color: var(--popover-foreground);
  font-size: var(--text-base);
}

.ui-menu .ui-state-active,
.ui-menu .ui-menu-item-wrapper.ui-state-active,
.ui-menu .ui-menu-item:hover {
  margin: 0 !important;
  border: 0 !important;
  background: var(--accent) !important;
  color: var(--accent-foreground) !important;
}

.ui-datepicker {
  width: 280px;
  padding: var(--space-3) !important;
}

.ui-datepicker .ui-datepicker-header {
  border: 0;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--foreground);
  font-weight: 600;
}

.ui-datepicker .ui-datepicker-prev,
.ui-datepicker .ui-datepicker-next {
  top: 4px;
  border-radius: var(--radius-md);
  cursor: pointer;
}

.ui-datepicker .ui-datepicker-prev-hover,
.ui-datepicker .ui-datepicker-next-hover {
  border: 0;
  background: var(--accent);
}

.ui-datepicker th {
  color: var(--muted-foreground);
  font-size: var(--text-xs);
  font-weight: 500;
}

.ui-datepicker td a,
.ui-datepicker td span,
.ui-state-default,
.ui-widget-content .ui-state-default {
  border: 0 !important;
  border-radius: var(--radius-sm);
  background: transparent !important;
  color: var(--foreground) !important;
  text-align: center;
}

.ui-datepicker td a:hover {
  background: var(--accent) !important;
}

.ui-state-highlight,
.ui-widget-content .ui-state-highlight {
  background: var(--secondary) !important;
}

.ui-state-active,
.ui-widget-content .ui-state-active {
  background: var(--primary) !important;
  color: var(--primary-foreground) !important;
}

.ui-slider {
  height: 6px;
  border: 0 !important;
  border-radius: var(--radius-full);
  background: var(--muted) !important;
}

.ui-slider .ui-slider-range {
  background: var(--brand) !important;
}

.ui-slider .ui-slider-handle {
  top: -6px;
  width: 18px;
  height: 18px;
  border: 2px solid var(--brand) !important;
  border-radius: var(--radius-full);
  background: var(--background) !important;
  box-shadow: var(--shadow-sm);
  cursor: grab;
}

/* ---------- emojionearea ---------- */

.emojionearea,
.emojionearea.form-control {
  border: 1px solid var(--input) !important;
  border-radius: var(--radius-md) !important;
  background: transparent !important;
  box-shadow: var(--shadow-xs) !important;
}

.emojionearea.focused {
  border-color: var(--ring) !important;
  box-shadow: 0 0 0 3px color-mix(in oklch, var(--ring) 25%, transparent) !important;
}

.emojionearea .emojionearea-editor {
  color: var(--foreground);
  font-size: var(--text-base);
}

.emojionearea .emojionearea-editor:empty:before {
  color: var(--muted-foreground) !important;
}

.emojionearea .emojionearea-picker {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--popover) !important;
  box-shadow: var(--shadow-lg);
}

.emojionearea .emojionearea-picker .emojionearea-wrapper:after {
  display: none;
}

.emojionearea .emojionearea-picker .emojionearea-filters,
.emojionearea .emojionearea-picker .emojionearea-search-panel,
.emojionearea .emojionearea-picker .emojionearea-tones-panel {
  background: transparent !important;
}

.emojionearea .emojionearea-picker .emojionearea-scroll-area .emojionearea-category-title {
  background: var(--popover) !important;
  color: var(--muted-foreground) !important;
}

/* ---------- tag-it ---------- */

ul.tagit {
  min-height: 40px;
  padding: var(--space-1) var(--space-2) !important;
  border: 1px solid var(--input) !important;
  border-radius: var(--radius-md) !important;
  background: transparent !important;
  box-shadow: var(--shadow-xs);
}

ul.tagit li.tagit-choice {
  padding: 2px 24px 2px var(--space-2) !important;
  border: 0 !important;
  border-radius: var(--radius-full) !important;
  background: var(--secondary) !important;
  color: var(--secondary-foreground) !important;
  font-size: var(--text-sm);
  font-weight: 500;
}

ul.tagit li.tagit-choice .tagit-close .text-icon,
ul.tagit li.tagit-choice .tagit-close .ui-icon {
  color: var(--muted-foreground);
}

ul.tagit input[type="text"] {
  height: 28px;
  border: 0 !important;
  background: transparent !important;
  color: var(--foreground) !important;
  box-shadow: none !important;
}

/* ---------- Swiper ---------- */

.swiper-button-next,
.swiper-button-prev {
  width: 36px !important;
  height: 36px !important;
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  background: var(--background);
  color: var(--foreground) !important;
  box-shadow: var(--shadow-md);
}

.swiper-button-next:after,
.swiper-button-prev:after {
  font-size: 14px !important;
  font-weight: 700;
}

.swiper-button-disabled {
  opacity: 0 !important;
}

.swiper-pagination-bullet {
  background: var(--muted-foreground);
}

.swiper-pagination-bullet-active {
  background: var(--foreground);
}

/* ---------- Players ---------- */

:root {
  --plyr-color-main: var(--brand);
  --plyr-font-family: var(--font-sans);
}

.mejs__container,
.video-js,
.plyr {
  font-family: var(--font-sans) !important;
}

.mejs__time-current,
.mejs__horizontal-volume-current,
.mejs__speed-selector-input:checked + label,
.video-js .vjs-play-progress,
.video-js .vjs-volume-level {
  background-color: var(--brand) !important;
}

.mejs__time-handle-content {
  border-color: var(--brand) !important;
}

.mejs__speed-selector,
.mejs__qualities-selector {
  border-radius: var(--radius-md);
  background: rgb(9 9 11 / 90%) !important;
}

/* ---------- Highcharts ---------- */

.highcharts-background,
.highcharts-root .highcharts-background {
  fill: transparent !important;
}

.highcharts-title,
.highcharts-axis-labels text,
.highcharts-legend-item text {
  color: var(--muted-foreground) !important;
  fill: var(--muted-foreground) !important;
  font-family: var(--font-sans) !important;
}

.highcharts-grid-line {
  stroke: var(--border) !important;
}

.highcharts-tooltip-box {
  fill: var(--popover) !important;
  stroke: var(--border) !important;
}

.highcharts-tooltip text {
  fill: var(--popover-foreground) !important;
}

/* ---------- Cookie consent ---------- */

.cc-window.cc-banner {
  z-index: var(--z-toast) !important;
  left: 50% !important;
  right: auto !important;
  bottom: var(--space-4) !important;
  width: calc(100% - 32px);
  max-width: 640px;
  padding: var(--space-3) var(--space-3) var(--space-3) var(--space-5) !important;
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: var(--popover) !important;
  color: var(--popover-foreground) !important;
  font-family: var(--font-sans);
  font-size: var(--text-base) !important;
  box-shadow: var(--shadow-lg);
  transform: translateX(-50%);
}

.cc-window .cc-link {
  color: var(--foreground) !important;
  opacity: 1;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.cc-window .cc-btn {
  min-width: 96px;
  padding: var(--space-2) var(--space-4) !important;
  border: 0 !important;
  border-radius: var(--radius-md);
  background-color: var(--primary) !important;
  color: var(--primary-foreground) !important;
  font-size: var(--text-base);
  font-weight: 500 !important;
}

@media (max-width: 767px) {
  .cc-window.cc-banner {
    bottom: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom) + 12px) !important;
    flex-direction: column;
    align-items: stretch !important;
    gap: var(--space-3);
    padding: var(--space-4) !important;
  }

  .cc-window.cc-banner .cc-btn {
    width: 100%;
  }
}
