/* Reset and base styles */
.crt-tabs-wrapper {
  display: flex;
  width: 100%;
  position: relative;
  background: transparent;
  box-sizing: border-box;
  margin: 0 auto;
  gap: 8px;
  contain: layout;
}

.crt-tabs-wrapper * {
  box-sizing: border-box;
}

/* Navigation */
.crt-tab-navigation {
  display: flex;
  background: #f7f7f7;
  flex-wrap: nowrap;
  scrollbar-width: none; /* Firefox */
  -webkit-overflow-scrolling: touch;
  border-radius: 6px;
  padding: 4px;
}

.crt-tab-navigation::-webkit-scrollbar { 
  display: none; 
}

.crt-tab-navigation .crt-tab {
  cursor: pointer;
  border: none;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  color: #333;
  margin: 2px;
  border-radius: 6px;
  font-weight: 600;
  transition: all 0.3s ease;
  padding: 12px 20px;
  white-space: nowrap;
  min-width: fit-content;
  flex-shrink: 0;
}

.crt-tab-navigation .crt-tab.active {
  outline: none;
  background: #ffcc00;
  color: #000;
  position: relative;
  z-index: 1;
}

.crt-tab-navigation .crt-tab:hover:not(.active),
.crt-tab-navigation .crt-tab:focus:not(.active) {
  outline: none;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.crt-tab-navigation .crt-tab:hover.active,
.crt-tab-navigation .crt-tab:focus.active {
  outline: none;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

/* Icon alignment */
.icon-align-left .crt-tab .crt-tab-icon {
  margin-right: 8px;
}

.icon-align-right .crt-tab .crt-tab-icon {
  order: 1;
  margin-left: 8px;
}

.icon-align-top .crt-tab {
  flex-direction: column;
  text-align: center;
}

.icon-align-top .crt-tab .crt-tab-icon {
  margin-bottom: 4px;
  margin-right: 0;
  margin-left: 0;
}

/* Icon only tabs */
.crt-tab .crt-tab-icon:only-child {
  margin: 0;
}

/* Label only tabs */
.crt-tab .crt-tab-label:only-child {
  margin: 0;
}

/* Content */
.crt-tabs-content-wrapper {
  flex: 1;
  padding: 20px;
  background: #fff;
  border-radius: 6px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
  position: relative;
  overflow: hidden;
}

/* Height type specific styles */
.crt-tabs-wrapper.height-auto .crt-tabs-content-wrapper {
  min-height: 200px;
  height: auto;
  overflow: visible;
}

.crt-tabs-wrapper.height-fixed .crt-tabs-content-wrapper {
  overflow-y: auto;
  overflow-x: hidden;
}

.crt-tabs-wrapper.height-min-max .crt-tabs-content-wrapper {
  overflow-y: auto;
  overflow-x: hidden;
}

.crt-tab-content {
  display: none;
  animation: fadeIn 0.3s ease-in-out;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

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

/* Ensure Elementor content doesn't overflow */
.crt-tab-content .elementor {
  max-width: 100%;
  overflow: hidden;
}

.crt-tab-content .elementor-section {
  overflow: hidden;
}

.crt-tab-content .elementor-container {
  max-width: 100%;
}

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

/* Layout Options - Desktop */

/* Desktop Top Position */
.desktop-pos-top {
  flex-direction: column;
}

.desktop-pos-top .crt-tab-navigation {
  flex-direction: row;
  overflow-x: auto;
  overflow-y: hidden;
  width: 100%;
  flex-shrink: 0;
}

/* Desktop Bottom Position */
.desktop-pos-bottom {
  flex-direction: column-reverse;
}

.desktop-pos-bottom .crt-tab-navigation {
  flex-direction: row;
  overflow-x: auto;
  overflow-y: hidden;
  width: 100%;
  flex-shrink: 0;
}

/* Desktop Left Position */
.desktop-pos-left {
  flex-direction: row;
}

.desktop-pos-left .crt-tab-navigation {
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  width: 200px;
  min-width: 150px;
  flex-shrink: 0;
}

/* Desktop Right Position */
.desktop-pos-right {
  flex-direction: row-reverse;
}

.desktop-pos-right .crt-tab-navigation {
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  width: 200px;
  min-width: 150px;
  flex-shrink: 0;
}

/* Mobile positions - Independent from desktop */
@media (max-width: 767px) {
  /* Mobile Top Position */
  .mobile-pos-top {
    flex-direction: column !important;
  }
  
  .mobile-pos-top .crt-tab-navigation {
    flex-direction: row !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    width: 100% !important;
  }
  
  /* Mobile Bottom Position */
  .mobile-pos-bottom {
    flex-direction: column-reverse !important;
  }
  
  .mobile-pos-bottom .crt-tab-navigation {
    flex-direction: row !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    width: 100% !important;
  }
  
  /* Mobile Left Position */
  .mobile-pos-left {
    flex-direction: row !important;
  }
  
  .mobile-pos-left .crt-tab-navigation {
    flex-direction: column !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    width: 120px !important;
    min-width: 100px !important;
  }
  
  /* Mobile Right Position */
  .mobile-pos-right {
    flex-direction: row-reverse !important;
  }
  
  .mobile-pos-right .crt-tab-navigation {
    flex-direction: column !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    width: 120px !important;
    min-width: 100px !important;
  }
}

/* Vertical tabs adjustments */
.desktop-pos-left .crt-tab-navigation .crt-tab,
.desktop-pos-right .crt-tab-navigation .crt-tab {
  width: 100%;
  margin: 2px 0;
  justify-content: flex-start;
}

@media (max-width: 767px) {
  .mobile-pos-left .crt-tab-navigation .crt-tab,
  .mobile-pos-right .crt-tab-navigation .crt-tab {
    width: 100% !important;
    margin: 2px 0 !important;
    justify-content: flex-start !important;
    padding: 8px 12px !important;
  }
}

/* Icon and label styling */
.crt-tab-icon i {
  font-size: 16px;
  transition: all 0.3s ease;
  display: inline-block;
}

.crt-tab:hover .crt-tab-icon i {
  transform: scale(1.1);
}

.crt-tab-label {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.2;
  transition: color 0.3s ease;
}

/* Separate icon and text color inheritance */
.crt-tab-navigation .crt-tab {
  color: inherit;
}

.crt-tab-navigation .crt-tab .crt-tab-icon i,
.crt-tab-navigation .crt-tab .crt-tab-label {
  color: inherit;
}

/* Hide elements when needed */
.crt-tab .crt-tab-icon:empty,
.crt-tab .crt-tab-label:empty {
  display: none;
}

/* Responsive improvements */
@media (max-width: 767px) {
  .crt-tabs-wrapper.height-auto {
    min-height: 250px;
  }
  
  .crt-tabs-content-wrapper {
    padding: 15px;
  }
  
  .crt-tab-navigation .crt-tab {
    padding: 10px 15px;
    font-size: 13px;
  }
  
  .crt-tab-icon i {
    font-size: 14px;
  }
  
  /* Mobile height adjustments */
  .crt-tabs-wrapper.height-fixed .crt-tabs-content-wrapper,
  .crt-tabs-wrapper.height-min-max .crt-tabs-content-wrapper {
    max-height: 70vh;
  }
}

@media (max-width: 480px) {
  .crt-tab-navigation .crt-tab {
    padding: 8px 12px;
    font-size: 12px;
  }
  
  .crt-tabs-content-wrapper {
    padding: 12px;
  }
}

/* Accessibility improvements */
.crt-tab:focus {
  outline: 2px solid #0073aa;
  outline-offset: 2px;
}

/* Loading state */
.crt-tabs-wrapper.loading .crt-tab-content {
  opacity: 0.7;
  pointer-events: none;
}

/* Error state */
.crt-tab-content.error,
.crt-tab-content .crt-error {
  color: #d63638;
  text-align: center;
  padding: 20px;
  background: #fef7f7;
  border: 1px solid #f5c6cb;
  border-radius: 4px;
  font-style: italic;
}

/* Container sizing utilities */
.crt-tabs-wrapper.full-width {
  width: 100% !important;
}

.crt-tabs-wrapper.auto-height {
  height: auto !important;
}

/* Custom scrollbar for better UX */
.crt-tab-navigation {
  scrollbar-width: thin;
  scrollbar-color: rgba(0,0,0,0.2) transparent;
}

.crt-tab-navigation::-webkit-scrollbar {
  width: 4px;
  height: 4px;
}

.crt-tab-navigation::-webkit-scrollbar-track {
  background: transparent;
}

.crt-tab-navigation::-webkit-scrollbar-thumb {
  background: rgba(0,0,0,0.2);
  border-radius: 2px;
}

.crt-tab-navigation::-webkit-scrollbar-thumb:hover {
  background: rgba(0,0,0,0.4);
}

/* Hide scrollbar on mobile for cleaner look */
@media (max-width: 767px) {
  .crt-tab-navigation::-webkit-scrollbar {
    display: none;
  }
  
  .crt-tab-navigation {
    scrollbar-width: none;
  }
  
  /* Mobile container adjustments */
  .crt-tabs-wrapper {
    max-width: 100% !important;
  }
}

/* Enhanced border and shadow support */
.crt-tab-navigation .crt-tab {
  border: 1px solid transparent;
}

/* Content area enhancements */
.crt-tabs-content-wrapper .elementor {
  width: 100%;
  max-width: 100%;
}

.crt-tabs-wrapper.height-auto .crt-tabs-content-wrapper .elementor-section-wrap {
  overflow: visible;
}

.crt-tabs-wrapper.height-fixed .crt-tabs-content-wrapper .elementor-section-wrap,
.crt-tabs-wrapper.height-min-max .crt-tabs-content-wrapper .elementor-section-wrap {
  overflow: hidden;
}

/* Template loading indicator */
.crt-tab-content.loading::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  margin: -10px 0 0 -10px;
  border: 2px solid #f3f3f3;
  border-top: 2px solid #3498db;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}