/* =========================================
   🚀 TERRAVIX ADVANCED COMPONENTS
   =========================================
   Premium UI Components Library
   Senior UX/UI Designer: Advanced Patterns
   ========================================= */

/* 🎭 MORPHING SEARCH BAR */
.terravix-search-morphing {
  position: relative;
  width: 240px;
  transition: all var(--duration-300) var(--ease-out);
}

.terravix-search-morphing.expanded {
  width: 100%;
  max-width: 480px;
}

.terravix-search-morphing .terravix-search-input {
  padding-right: var(--space-16);
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
}

.terravix-search-morphing .terravix-search-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: white;
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-xl);
  margin-top: var(--space-2);
  box-shadow: var(--shadow-2xl);
  backdrop-filter: var(--glass-blur);
  z-index: var(--z-dropdown);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition: all var(--duration-200) var(--ease-out);
}

.terravix-search-morphing.has-results .terravix-search-results {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.terravix-search-result-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--slate-100);
  cursor: pointer;
  transition: all var(--duration-150) var(--ease-out);
}

.terravix-search-result-item:hover {
  background: var(--brand-25);
  transform: translateX(3.2px);
}

.terravix-search-result-item:last-child {
  border-bottom: none;
  border-radius: 0 0 var(--radius-xl) var(--radius-xl);
}

.terravix-search-result-item:first-child {
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
}

/* 🎨 GRADIENT PROGRESS BAR */
.terravix-progress-container {
  width: 100%;
  height: 6.4px;
  background: var(--slate-200);
  border-radius: var(--radius-full);
  overflow: hidden;
  position: relative;
}

.terravix-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--brand-400) 0%, var(--brand-500) 50%, var(--brand-600) 100%);
  border-radius: var(--radius-full);
  transition: width var(--duration-300) var(--ease-out);
  position: relative;
  overflow: hidden;
}

.terravix-progress-bar::after {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent 0%, rgba(255, 255, 255, 0.3) 50%, transparent 100%);
  animation: progress-shine 2s infinite;
}

@keyframes progress-shine {
  0% { left: -100%; }
  100% { left: 100%; }
}

/* 🌟 FLOATING ACTION BUTTON */
.terravix-fab {
  position: fixed;
  bottom: var(--space-8);
  right: var(--space-8);
  width: 51.2px;
  height: 51.2px;
  background: linear-gradient(135deg, var(--brand-500) 0%, var(--brand-600) 100%);
  border: none;
  border-radius: var(--radius-full);
  color: white;
  cursor: pointer;
  box-shadow: var(--shadow-brand-lg);
  transition: all var(--duration-300) var(--ease-out);
  z-index: var(--z-fixed);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-2xl);
}

.terravix-fab:hover {
  transform: scale(1.1) translateY(-1.6px);
  box-shadow: var(--shadow-brand-xl);
}

.terravix-fab:active {
  transform: scale(0.95);
}

.terravix-fab.expanded {
  width: auto;
  padding: 0 var(--space-6);
  border-radius: var(--radius-full);
}

.terravix-fab-menu {
  position: absolute;
  bottom: 64px;
  right: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  opacity: 0;
  visibility: hidden;
  transform: scale(0.8);
  transition: all var(--duration-200) var(--ease-back);
}

.terravix-fab.open .terravix-fab-menu {
  opacity: 1;
  visibility: visible;
  transform: scale(1);
}

.terravix-fab-menu-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: white;
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-full);
  color: var(--slate-700);
  text-decoration: none;
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  white-space: nowrap;
  box-shadow: var(--shadow-lg);
  transition: all var(--duration-200) var(--ease-out);
}

.terravix-fab-menu-item:hover {
  background: var(--brand-50);
  color: var(--brand-700);
  transform: translateX(-3.2px);
  box-shadow: var(--shadow-xl);
}

/* 🎪 MODAL SYSTEM */
.terravix-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: none;
  z-index: var(--z-modal-backdrop);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  opacity: 0;
  visibility: hidden;
  transition: all var(--duration-300) var(--ease-out);
}

.terravix-modal-overlay.open {
  opacity: 1;
  visibility: visible;
}

.terravix-modal {
  background: white;
  border-radius: var(--radius-2xl);
  box-shadow: var(--shadow-2xl);
  max-width: 90vw;
  max-height: 90vh;
  overflow: hidden;
  transform: scale(0.9) translateY(16px);
  transition: all var(--duration-300) var(--ease-back);
  position: relative;
}

.terravix-modal-overlay.open .terravix-modal {
  transform: scale(1) translateY(0);
}

.terravix-modal-header {
  padding: var(--space-6);
  border-bottom: 1px solid var(--slate-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(135deg, var(--slate-25) 0%, white 100%);
}

.terravix-modal-title {
  font-size: var(--text-xl);
  font-weight: var(--font-bold);
  color: var(--slate-900);
  margin: 0;
}

.terravix-modal-close {
  background: none;
  border: none;
  color: var(--slate-400);
  font-size: var(--text-2xl);
  cursor: pointer;
  padding: var(--space-2);
  border-radius: var(--radius-lg);
  transition: all var(--duration-150) var(--ease-out);
}

.terravix-modal-close:hover {
  background: var(--slate-100);
  color: var(--slate-600);
}

.terravix-modal-body {
  padding: var(--space-6);
  overflow-y: auto;
  max-height: 60vh;
}

.terravix-modal-footer {
  padding: var(--space-6);
  border-top: 1px solid var(--slate-200);
  display: flex;
  gap: var(--space-3);
  justify-content: flex-end;
  background: var(--slate-25);
}

/* 🎯 ADVANCED DROPDOWN */
.terravix-dropdown {
  position: relative;
  display: inline-block;
}

.terravix-dropdown-trigger {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  background: white;
  border: 1px solid var(--slate-300);
  border-radius: var(--radius-lg);
  color: var(--slate-700);
  cursor: pointer;
  transition: all var(--duration-150) var(--ease-out);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
}

.terravix-dropdown-trigger:hover {
  border-color: var(--brand-300);
  box-shadow: var(--shadow-sm);
}

.terravix-dropdown-trigger.open {
  border-color: var(--brand-500);
  box-shadow: var(--shadow-brand-md);
}

.terravix-dropdown-menu {
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 160px;
  background: white;
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  z-index: var(--z-dropdown);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition: all var(--duration-200) var(--ease-out);
  overflow: hidden;
  margin-top: var(--space-2);
}

.terravix-dropdown.open .terravix-dropdown-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.terravix-dropdown-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  color: var(--slate-700);
  text-decoration: none;
  transition: all var(--duration-150) var(--ease-out);
  cursor: pointer;
  border-bottom: 1px solid var(--slate-100);
}

.terravix-dropdown-item:hover {
  background: var(--brand-25);
  color: var(--brand-700);
  transform: translateX(3.2px);
}

.terravix-dropdown-item:last-child {
  border-bottom: none;
}

.terravix-dropdown-item.active {
  background: var(--brand-50);
  color: var(--brand-700);
  font-weight: var(--font-semibold);
}

/* 🏷️ ADVANCED TAGS */
.terravix-tag {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1-5) var(--space-3);
  background: var(--slate-100);
  color: var(--slate-700);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: var(--font-medium);
  transition: all var(--duration-150) var(--ease-out);
  border: 1px solid var(--slate-200);
}

.terravix-tag.variant-brand {
  background: var(--brand-100);
  color: var(--brand-700);
  border-color: var(--brand-200);
}

.terravix-tag.variant-success {
  background: var(--success-100);
  color: var(--success-700);
  border-color: var(--success-200);
}

.terravix-tag.variant-warning {
  background: var(--warning-100);
  color: var(--warning-700);
  border-color: var(--warning-200);
}

.terravix-tag.variant-error {
  background: var(--error-100);
  color: var(--error-700);
  border-color: var(--error-200);
}

.terravix-tag-close {
  background: none;
  border: none;
  color: currentColor;
  cursor: pointer;
  padding: var(--space-1);
  border-radius: var(--radius-full);
  transition: all var(--duration-150) var(--ease-out);
  margin-left: var(--space-1);
}

.terravix-tag-close:hover {
  background: rgba(0, 0, 0, 0.1);
}

/* 📊 CHART CONTAINER */
.terravix-chart-container {
  background: white;
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-2xl);
  padding: var(--space-6);
  box-shadow: var(--shadow-lg);
  position: relative;
  overflow: hidden;
}

.terravix-chart-container::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3.2px;
  background: linear-gradient(90deg, var(--brand-500) 0%, var(--brand-400) 100%);
}

.terravix-chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-6);
}

.terravix-chart-title {
  font-size: var(--text-lg);
  font-weight: var(--font-bold);
  color: var(--slate-900);
  margin: 0;
}

.terravix-chart-subtitle {
  font-size: var(--text-sm);
  color: var(--slate-600);
  margin: var(--space-1) 0 0 0;
}

/* 🎨 STATUS INDICATORS */
.terravix-status-indicator {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.terravix-status-indicator.online {
  background: var(--success-100);
  color: var(--success-700);
}

.terravix-status-indicator.offline {
  background: var(--error-100);
  color: var(--error-700);
}

.terravix-status-indicator.pending {
  background: var(--warning-100);
  color: var(--warning-700);
}

.terravix-status-indicator.processing {
  background: var(--info-100);
  color: var(--info-700);
}

.terravix-status-dot {
  width: 6.4px;
  height: 6.4px;
  border-radius: var(--radius-full);
  background: currentColor;
}

.terravix-status-indicator.online .terravix-status-dot {
  animation: pulse-green 2s infinite;
}

.terravix-status-indicator.processing .terravix-status-dot {
  animation: pulse-blue 2s infinite;
}

@keyframes pulse-green {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

@keyframes pulse-blue {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* 🎪 ACCORDION COMPONENT */
.terravix-accordion {
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-xl);
  overflow: hidden;
  background: white;
}

.terravix-accordion-item {
  border-bottom: 1px solid var(--slate-200);
}

.terravix-accordion-item:last-child {
  border-bottom: none;
}

.terravix-accordion-trigger {
  width: 100%;
  padding: var(--space-4) var(--space-6);
  background: none;
  border: none;
  text-align: left;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: var(--text-base);
  font-weight: var(--font-semibold);
  color: var(--slate-900);
  transition: all var(--duration-200) var(--ease-out);
}

.terravix-accordion-trigger:hover {
  background: var(--slate-25);
}

.terravix-accordion-trigger.open {
  background: var(--brand-25);
  color: var(--brand-700);
}

.terravix-accordion-icon {
  transition: transform var(--duration-200) var(--ease-out);
}

.terravix-accordion-trigger.open .terravix-accordion-icon {
  transform: rotate(180deg);
}

.terravix-accordion-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height var(--duration-300) var(--ease-out);
}

.terravix-accordion-content.open {
  max-height: 800px;
}

.terravix-accordion-body {
  padding: 0 var(--space-6) var(--space-4) var(--space-6);
  color: var(--slate-600);
  line-height: 1.6;
}

/* 📝 FORM ENHANCEMENTS */
.terravix-form-group {
  margin-bottom: var(--space-6);
}

.terravix-form-label {
  display: block;
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
  color: var(--slate-700);
  margin-bottom: var(--space-2);
}

.terravix-form-input {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--slate-300);
  border-radius: var(--radius-lg);
  font-size: var(--text-sm);
  color: var(--slate-900);
  background: white;
  transition: all var(--duration-200) var(--ease-out);
}

.terravix-form-input:focus {
  outline: none;
  border-color: var(--brand-500);
  box-shadow: var(--shadow-brand-md);
  transform: translateY(-1px);
}

.terravix-form-input.error {
  border-color: var(--error-500);
  box-shadow: 0 0 0 2.4px rgba(239, 68, 68, 0.1);
}

.terravix-form-error {
  font-size: var(--text-xs);
  color: var(--error-600);
  margin-top: var(--space-1);
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

.terravix-form-help {
  font-size: var(--text-xs);
  color: var(--slate-500);
  margin-top: var(--space-1);
}

/* 🎨 THEME SWITCHER */
.terravix-theme-switcher {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3);
  background: var(--slate-25);
  border-radius: var(--radius-xl);
}

.terravix-theme-option {
  width: 25.6px;
  height: 25.6px;
  border-radius: var(--radius-full);
  border: 1.6px solid var(--slate-200);
  cursor: pointer;
  transition: all var(--duration-200) var(--ease-out);
  position: relative;
}

.terravix-theme-option:hover {
  transform: scale(1.1);
  box-shadow: var(--shadow-lg);
}

.terravix-theme-option.active {
  border-color: var(--brand-500);
  box-shadow: var(--shadow-brand-md);
}

.terravix-theme-option.active::after {
  content: '✓';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: white;
  font-size: var(--text-xs);
  font-weight: var(--font-bold);
}

.terravix-theme-emerald { background: var(--emerald-500); }
.terravix-theme-blue { background: #3b82f6; }
.terravix-theme-purple { background: #8b5cf6; }
.terravix-theme-pink { background: #ec4899; }
.terravix-theme-orange { background: #f97316; }
