.animate-fade-in {
  animation: fadeIn 0.3s ease-out forwards;
}

.animate-slide-in {
  animation: slideIn 0.3s ease-out forwards;
}

.animate-bounce {
  animation: bounce 0.5s ease;
}

/* Keyframes */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

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

@keyframes bounce {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-5px);
  }
}

@keyframes pulse {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes spinIn {
  from {
    transform: rotate(-10deg) scale(0.9);
    opacity: 0;
  }
  to {
    transform: rotate(0) scale(1);
    opacity: 1;
  }
}

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

@keyframes dropdownFadeIn {
  from {
    opacity: 0;
    transform: translateY(-8px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Component */
/* Button */
.btn {
  transition: all 0.2s ease-in-out !important;
}

.btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.btn:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.btn-primary:hover:not(:disabled) {
  box-shadow: 0 4px 12px rgba(13, 202, 240, 0.4);
}

.btn-outline-primary:hover:not(:disabled),
.btn-outline-secondary:hover:not(:disabled) {
  transform: translateY(-2px) scale(1.02);
}

/* i didn't use 'all' for this because it breaks textarea resize */
.form-control {
  transition:
    border 0.3s ease-in-out,
    box-shadow 0.3s ease-in-out,
    transform 0.3s ease-in-out,
    color 0.3s ease-in-out,
    background-color 0.3s ease-in-out;
}

.form-control:focus {
  box-shadow: 0 0 0 0.25rem rgba(13, 202, 240, 0.25);
  border-color: rgba(13, 202, 240, 0.5);
  transform: translateY(-1px);
}

/* Card */
.card {
  transition:
    transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275),
    box-shadow 0.3s ease,
    border-color 0.3s ease;
}

.card:hover {
  transform: translateY(-5px);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.15);
  border-color: rgba(13, 202, 240, 0.5) !important;
}

/* Modal */
.modal.fade .modal-dialog {
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) !important;
  transform: scale(0.95) !important;
}

.modal.show .modal-dialog {
  transform: scale(1) !important;
}

.modal-content {
  animation: fadeIn 0.3s forwards !important;
}

.modal-header,
.modal-footer {
  animation: slideIn 0.3s forwards !important;
}

.modal-footer {
  z-index: -1;
}

.modal.fade:not(.show) .modal-dialog {
  transform: scale(0.95) !important;
}

.modal.fade.show .modal-dialog {
  transform: scale(1) !important;
}

@media (prefers-reduced-motion: reduce) {
  .modal.fade .modal-dialog {
    transition: none !important;
    transform: none !important;
  }

  .modal-content,
  .modal-header,
  .modal-footer {
    animation: none !important;
  }
}

/* Sidebar */
.aside {
  transition:
    width 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275),
    min-width 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.container-main.sidebar-collapsed .aside {
  transition:
    width 0.4s cubic-bezier(0.6, 0.04, 0.98, 0.335),
    min-width 0.4s cubic-bezier(0.6, 0.04, 0.98, 0.335);
}

/* Sidebar Toggle button */
#sidebar-toggle {
  transition:
    transform 0.4s cubic-bezier(0.68, -0.55, 0.27, 1.55),
    opacity 0.3s ease,
    background-color 0.2s ease !important;
}

/* Content loading */
main[role="main"] > div:not(.d-none) {
  animation: fadeIn 0.4s forwards;
}

/* UpgradeViewer */
#side-upgrade-extras-add,
#side-upgrade-extras-add-group,
#side-ability-add {
  transition: all 0.2s ease;
}

#side-upgrade-extras-add:hover,
#side-upgrade-extras-add-group:hover,
#side-ability-add:hover {
  transform: scale(1.03);
}

/* Collapsible Groups */
.collapse {
  transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.collapse:not(.show) {
  display: block;
  height: 0;
  overflow: hidden;
  opacity: 0;
  transform: translateY(-10px);
}

.collapse.show {
  height: auto;
  opacity: 1;
  transform: translateY(0);
}

/* tower name changes */
#tower-name {
  transition: all 0.3s ease;
}

#tower-name:not(:has(.spinner-border)) {
  animation: slideInRight 0.4s forwards;
}

/* When buttons are clicked */
.btn:active:not(:disabled) {
  animation: pulse 0.3s ease;
}

/* Table management buttons */
#table-clear,
#table-apply,
#table-reset,
#table-clear-data,
#table-unit-clear,
#table-unit-apply,
#table-unit-reset {
  transition: all 0.2s ease !important;
}

/* bounce effect to notifs */
#alert-container .alert {
  animation:
    slideIn 0.3s ease forwards,
    fadeIn 0.3s ease forwards;
}

/* tab switching in modals */
.modal-body > div:not(.d-none) {
  animation: fadeIn 0.3s forwards;
}

/* Propertyviewer button */
#property-viewer button {
  transition: all 0.2s ease;
}

#property-viewer button:hover {
  transform: translateX(3px);
}

/* Tower search input */
#Tower-Selector input {
  transition: all 0.3s ease;
}

#Tower-Selector input:focus {
  box-shadow: 0 0 0 0.25rem rgba(13, 202, 240, 0.25);
  transform: translateY(-2px);
}

/* Dropdown items */
.dropdown-item {
  transition: all 0.15s ease-out;
}

.dropdown-item:hover {
  background-color: rgba(13, 202, 240, 0.1) !important;
  padding-left: 1.8rem;
}

/* dropdown hover indicator */
.dropdown-item:hover::before {
  content: "";
  position: absolute;
  left: 1rem;
  top: 50%;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background-color: rgba(13, 202, 240, 0.8);
  transform: translateY(-50%);
  animation: fadeIn 0.2s forwards;
}

/* active dropdown item */
.dropdown-item.active,
.dropdown-item:active {
  transition: all 0.1s ease-out;
  transform: scale(0.98);
}

/* dropdown menu */
.dropdown-menu {
  transition:
    transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275),
    opacity 0.2s ease,
    box-shadow 0.3s ease;
  transform-origin: top center;
}

#Tower-Selector .dropdown-menu {
  display: none;
}

#Tower-Selector .dropdown-menu.d-block {
  display: block;
  animation: dropdownFadeIn 0.2s forwards;
}

.form-check-input {
  transition: all 0.2s ease !important;
}
