/* =========================================
   RESPONSIVE & INTERACTIVE ELEMENTS v4.0
   Micro-interactions & Adaptive Layout
   ========================================= */

/* ─── LOADING STATES ─── */
@keyframes shimmer-loading {
  0% {
    background-position: -1000px 0;
  }
  100% {
    background-position: 1000px 0;
  }
}

@keyframes pulse-breathe {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.7;
  }
}

@keyframes spin-smooth {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

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

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(168, 85, 247, 0.2);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin-smooth 1s linear infinite;
}

.loading-pulse {
  animation: pulse-breathe 2s ease-in-out infinite;
}

.loading-shimmer {
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.1) 20%,
    rgba(255, 255, 255, 0.2) 60%,
    transparent 100%
  );
  background-size: 1000px 100%;
  animation: shimmer-loading 2s infinite;
}

/* ─── SKELETONS ─── */
.skeleton {
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.05));
  background-size: 200% 100%;
  animation: shimmer-loading 1.5s infinite;
  border-radius: 8px;
}

.skeleton-text {
  height: 14px;
  margin-bottom: 8px;
}

.skeleton-heading {
  height: 24px;
  width: 60%;
  margin-bottom: 16px;
}

.skeleton-image {
  width: 100%;
  padding-bottom: 66.67%;
  margin-bottom: 16px;
}

/* ─── TOOLTIP SYSTEM ─── */
.tooltip-wrapper {
  position: relative;
  display: inline-block;
}

.tooltip {
  visibility: hidden;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  text-align: center;
  padding: 8px 12px;
  border-radius: 8px;
  position: absolute;
  z-index: 1000;
  bottom: 125%;
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  font-size: 12px;
  font-weight: 500;
  opacity: 0;
  transition: opacity 0.3s ease;
  box-shadow: 0 4px 12px rgba(168, 85, 247, 0.3);
  pointer-events: none;
}

.tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  margin-left: -5px;
  border-width: 5px;
  border-style: solid;
  border-color: var(--primary) transparent transparent transparent;
}

.tooltip-wrapper:hover .tooltip {
  visibility: visible;
  opacity: 1;
}

/* ─── DROPDOWN MENU ─── */
.dropdown {
  position: relative;
  display: inline-block;
}

.dropdown-toggle {
  background: transparent;
  border: 1px solid rgba(168, 85, 247, 0.3);
  color: var(--text-primary);
  padding: 10px 16px;
  cursor: pointer;
  border-radius: 8px;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: 8px;
}

.dropdown-toggle:hover {
  background: rgba(168, 85, 247, 0.1);
  border-color: var(--primary);
  color: var(--primary);
}

.dropdown-menu {
  display: none;
  position: absolute;
  background: linear-gradient(135deg, rgba(13, 13, 30, 0.98), rgba(20, 20, 45, 0.95));
  min-width: 200px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  z-index: 999;
  border: 1px solid rgba(168, 85, 247, 0.2);
  border-radius: 12px;
  overflow: hidden;
  backdrop-filter: blur(10px);
  animation: slideInUp 0.3s ease-out;
  top: 100%;
  left: 0;
  margin-top: 8px;
}

.dropdown:hover .dropdown-menu,
.dropdown.active .dropdown-menu {
  display: block;
}

.dropdown-item {
  color: var(--text-secondary);
  padding: 12px 16px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  white-space: nowrap;
}

.dropdown-item:hover {
  background: rgba(168, 85, 247, 0.15);
  color: var(--primary);
  padding-left: 20px;
}

.dropdown-divider {
  height: 1px;
  background: rgba(168, 85, 247, 0.1);
  margin: 4px 0;
}

/* ─── MODAL ANIMATIONS ─── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 999;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
  backdrop-filter: blur(5px);
}

.modal-backdrop.active {
  opacity: 1;
  visibility: visible;
}

.modal-dialog {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
  animation: none;
}

.modal-dialog.active {
  opacity: 1;
  visibility: visible;
  animation: slideInUp 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-content {
  background: linear-gradient(135deg, var(--bg-surface), var(--bg-medium));
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  padding: 32px;
  max-width: 500px;
  width: 100%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  position: relative;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid rgba(168, 85, 247, 0.1);
}

.modal-title {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 24px;
  cursor: pointer;
  transition: all 0.2s ease;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-close:hover {
  color: var(--primary);
  transform: rotate(90deg);
}

.modal-body {
  margin-bottom: 20px;
  color: var(--text-secondary);
  line-height: 1.6;
}

.modal-footer {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

/* ─── TABS COMPONENT ─── */
.tabs {
  display: flex;
  border-bottom: 1px solid rgba(168, 85, 247, 0.1);
  gap: 0;
  margin-bottom: 20px;
}

.tab-btn {
  padding: 12px 20px;
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  position: relative;
  transition: color 0.3s ease;
  font-size: 14px;
  font-weight: 500;
}

.tab-btn::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--primary);
  transform: scaleX(0);
  transform-origin: center;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.tab-btn:hover {
  color: var(--text-primary);
}

.tab-btn.active {
  color: var(--primary);
}

.tab-btn.active::after {
  transform: scaleX(1);
}

.tab-content {
  display: none;
  animation: fadeInScale 0.3s ease-out;
}

.tab-content.active {
  display: block;
}

/* ─── TOGGLE SWITCH ─── */
.toggle-switch {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  gap: 8px;
}

.toggle-input {
  display: none;
}

.toggle-slider {
  position: relative;
  width: 48px;
  height: 24px;
  background: rgba(168, 85, 247, 0.2);
  border: 1px solid rgba(168, 85, 247, 0.3);
  border-radius: 12px;
  transition: all 0.3s ease;
}

.toggle-slider::after {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  background: white;
  border-radius: 50%;
  top: 1px;
  left: 1px;
  transition: all 0.3s ease;
}

.toggle-input:checked + .toggle-slider {
  background: var(--primary);
  border-color: var(--primary);
}

.toggle-input:checked + .toggle-slider::after {
  transform: translateX(24px);
}

/* ─── ACCORDION ─── */
.accordion {
  border: 1px solid rgba(168, 85, 247, 0.1);
  border-radius: 12px;
  overflow: hidden;
}

.accordion-item {
  border-bottom: 1px solid rgba(168, 85, 247, 0.1);
}

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

.accordion-header {
  padding: 16px;
  background: rgba(168, 85, 247, 0.04);
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  justify-content: space-between;
  align-items: center;
  user-select: none;
}

.accordion-header:hover {
  background: rgba(168, 85, 247, 0.08);
  color: var(--primary);
}

.accordion-header.active {
  background: rgba(168, 85, 247, 0.12);
  color: var(--primary);
}

.accordion-icon {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.3s ease;
}

.accordion-header.active .accordion-icon {
  transform: rotate(180deg);
}

.accordion-body {
  padding: 16px;
  color: var(--text-secondary);
  line-height: 1.6;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
}

.accordion-item.active .accordion-body {
  max-height: 1000px;
}

/* ─── PROGRESS BAR ─── */
.progress {
  width: 100%;
  height: 4px;
  background: rgba(168, 85, 247, 0.1);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 16px;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--tertiary));
  width: 0%;
  transition: width 0.5s cubic-bezier(0.23, 1, 0.32, 1);
  box-shadow: 0 0 10px var(--glow-primary);
}

.progress-text {
  font-size: 12px;
  color: var(--text-secondary);
  text-align: right;
  margin-top: 4px;
}

/* ─── ALERT/NOTIFICATION ─── */
.alert {
  padding: 16px;
  border-radius: 10px;
  margin-bottom: 16px;
  border: 1px solid;
  display: flex;
  gap: 12px;
  align-items: flex-start;
  animation: slideInDown 0.4s ease-out;
}

.alert-icon {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-weight: 600;
  border-radius: 50%;
}

.alert-content {
  flex: 1;
}

.alert-title {
  font-weight: 600;
  margin-bottom: 4px;
}

.alert-message {
  font-size: 13px;
  line-height: 1.5;
}

/* Alert Types */
.alert-success {
  background: rgba(16, 185, 129, 0.1);
  border-color: rgba(16, 185, 129, 0.3);
  color: var(--accent-green-bright);
}

.alert-success .alert-icon {
  background: rgba(16, 185, 129, 0.2);
}

.alert-warning {
  background: rgba(245, 158, 11, 0.1);
  border-color: rgba(245, 158, 11, 0.3);
  color: var(--accent-gold);
}

.alert-warning .alert-icon {
  background: rgba(245, 158, 11, 0.2);
}

.alert-error {
  background: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.3);
  color: var(--accent-red);
}

.alert-error .alert-icon {
  background: rgba(239, 68, 68, 0.2);
}

.alert-info {
  background: rgba(6, 214, 255, 0.1);
  border-color: rgba(6, 214, 255, 0.3);
  color: var(--tertiary);
}

.alert-info .alert-icon {
  background: rgba(6, 214, 255, 0.2);
}

/* Close button for alerts */
.alert-close {
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  font-size: 18px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.alert-close:hover {
  opacity: 0.7;
}

/* ─── RESPONSIVE IMPROVEMENTS ─── */
@media (max-width: 768px) {
  .modal-content {
    padding: 24px;
  }

  .tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .accordion-header {
    padding: 12px;
  }

  .accordion-body {
    padding: 12px;
  }
}

/* ─── DARK/LIGHT MODE SMOOTH TRANSITION ─── */
html {
  transition: background-color 0.3s ease, color 0.3s ease;
}

[data-theme="light"] .alert-success {
  background: rgba(16, 185, 129, 0.15);
}

[data-theme="light"] .alert-warning {
  background: rgba(245, 158, 11, 0.15);
}

[data-theme="light"] .alert-error {
  background: rgba(239, 68, 68, 0.15);
}

[data-theme="light"] .alert-info {
  background: rgba(6, 214, 255, 0.15);
}
