/**
 * Frontend CSS cho Cell Groups System
 * 
 * QUAN TRỌNG:
 * - TẤT CẢ classes được namespace với .htns-cell-groups-wrapper
 * - TÁI SỬ DỤNG các biến CSS từ :root (--primary-color, --secondary-color, etc.)
 * - CSS này COPY CHÍNH XÁC từ file gốc styles.css (lines 1230-1535)
 * - Giữ nguyên tất cả giá trị border, padding, font-size, colors
 * 
 * @package HTNS_Cell_Groups
 */

/* ==========================================================================
   Reset & Base Styles - Scoped trong wrapper
   ========================================================================== */

.htns-cell-groups-wrapper *,
.htns-cell-groups-wrapper *::before,
.htns-cell-groups-wrapper *::after {
  box-sizing: border-box;
}

.htns-cell-groups-wrapper {
  width: 100%;
  margin: 0 auto;
  position: relative;
}

/* Reset headings trong wrapper */
.htns-cell-groups-wrapper h3,
.htns-cell-groups-wrapper h4 {
  margin: 0;
  padding: 0;
  font-weight: 600;
  line-height: 1.3;
}

/* ==========================================================================
   Cell Groups Wrapper - Main Container
   ========================================================================== */

.htns-cell-groups-wrapper.cell-groups-wrapper {
  display: grid;
  grid-template-columns: 30% 70%;
  gap: 20px;
  margin-top: 30px;
}

/* ==========================================================================
   Cell Groups List - Sidebar
   ========================================================================== */

.htns-cell-groups-wrapper .cell-groups-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 420px;
  overflow-y: auto;
  padding-right: 8px;
}

/* Custom Scrollbar */
.htns-cell-groups-wrapper .cell-groups-list::-webkit-scrollbar {
  width: 6px;
}

.htns-cell-groups-wrapper .cell-groups-list::-webkit-scrollbar-track {
  background: var(--light-gray, #f5f5f5);
  border-radius: 10px;
}

.htns-cell-groups-wrapper .cell-groups-list::-webkit-scrollbar-thumb {
  background: var(--primary-color, #0b3678);
  border-radius: 10px;
}

/* ==========================================================================
   Cell Group Card
   ========================================================================== */

.htns-cell-groups-wrapper .cell-group-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg-light, #f9f9f9);
  border-radius: 8px;
  border: 2px solid transparent;
  transition: var(--transition, all 0.3s ease);
  cursor: pointer;
}

.htns-cell-groups-wrapper .cell-group-card:hover {
  border-color: var(--primary-lighter, #3674d9);
  background: var(--white, #ffffff);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1);
  transform: translateX(3px);
}

.htns-cell-groups-wrapper .cell-group-card.active {
  border-color: var(--primary-color, #0b3678);
  background: var(--white, #ffffff);
  box-shadow: 0 5px 15px rgba(11, 54, 120, 0.15);
}

/* ==========================================================================
   Cell Group Icon
   ========================================================================== */

.htns-cell-groups-wrapper .cell-group-icon {
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, var(--primary-color, #0b3678), var(--primary-light, #1254b9));
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--white, #ffffff);
  font-size: 1rem;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(11, 54, 120, 0.2);
  transition: var(--transition, all 0.3s ease);
}

.htns-cell-groups-wrapper .cell-group-card.active .cell-group-icon {
  background: linear-gradient(135deg, var(--secondary-color, #ed920e), var(--secondary-light, #ffa62b));
  animation: pulse 2s infinite;
}

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

/* ==========================================================================
   Cell Group Info
   ========================================================================== */

.htns-cell-groups-wrapper .cell-group-info {
  flex: 1;
  min-width: 0;
}

.htns-cell-groups-wrapper .cell-group-name {
  color: var(--primary-color, #0b3678);
  font-size: 0.95rem;
  margin-bottom: 4px;
  font-weight: 600;
  line-height: 1.2;
}

.htns-cell-groups-wrapper .cell-group-address {
  display: flex;
  align-items: flex-start;
  gap: 5px;
  font-size: 0.8rem;
  color: var(--dark-gray, #333333);
  line-height: 1.3;
}

.htns-cell-groups-wrapper .cell-group-address i {
  color: var(--secondary-color, #ed920e);
  margin-top: 2px;
  flex-shrink: 0;
  font-size: 0.9rem;
}

/* ==========================================================================
   Cell Group Button (Chevron)
   ========================================================================== */

.htns-cell-groups-wrapper .cell-group-btn {
  width: 30px;
  height: 30px;
  background: var(--primary-lighter, #3674d9);
  color: var(--white, #ffffff);
  border: none;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition, all 0.3s ease);
  flex-shrink: 0;
  font-size: 0.9rem;
}

.htns-cell-groups-wrapper .cell-group-card.active .cell-group-btn {
  background: var(--primary-color, #0b3678);
}

.htns-cell-groups-wrapper .cell-group-btn:hover {
  background: var(--secondary-color, #ed920e);
  transform: scale(1.1);
}

/* ==========================================================================
   Map & Details Wrapper
   ========================================================================== */

.htns-cell-groups-wrapper .cell-groups-map-wrapper {
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: sticky;
  top: 100px;
  height: fit-content;
}

/* ==========================================================================
   Map Container - Responsive với Aspect Ratio
   ========================================================================== */

.htns-cell-groups-wrapper .cell-groups-map {
  position: relative;
  width: 100%;
  height: 450px; /* Default height, có thể override bằng inline style */
  min-height: 300px;
}

.htns-cell-groups-wrapper .map-container {
  height: 100%;
  width: 100%;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 5px 20px rgba(0, 0, 0, 0.1);
  position: relative;
  background: var(--light-gray, #f5f5f5);
}

/* Loading state */
.htns-cell-groups-wrapper .map-container.loading::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.8);
  z-index: 10;
}

/* Iframe responsive - fill container */
.htns-cell-groups-wrapper .map-container iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}

/* ==========================================================================
   Compact Details Panel
   ========================================================================== */

.htns-cell-groups-wrapper .cell-group-details-compact {
  background: var(--white, #ffffff);
  border-radius: 10px;
  padding: 15px;
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.08);
  border-left: 4px solid var(--primary-color, #0b3678);
  transition: opacity 0.3s ease;
}

.htns-cell-groups-wrapper .details-compact-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.htns-cell-groups-wrapper .details-title {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.htns-cell-groups-wrapper .details-title i {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--secondary-color, #ed920e), var(--secondary-light, #ffa62b));
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--white, #ffffff);
  font-size: 1rem;
  flex-shrink: 0;
}

.htns-cell-groups-wrapper .details-title h4 {
  color: var(--primary-color, #0b3678);
  font-size: 1rem;
  font-weight: 700;
  margin: 0;
  line-height: 1.3;
}

/* ==========================================================================
   Quick Actions Buttons
   ========================================================================== */

.htns-cell-groups-wrapper .details-quick-actions {
  display: flex;
  gap: 8px;
}

.htns-cell-groups-wrapper .btn-icon {
  width: 36px;
  height: 36px;
  background: var(--primary-lighter, #3674d9);
  color: var(--white, #ffffff);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition, all 0.3s ease);
  font-size: 0.9rem;
  flex-shrink: 0;
  text-decoration: none;
}

.htns-cell-groups-wrapper .btn-icon:hover {
  background: var(--secondary-color, #ed920e);
  transform: scale(1.1);
}

/* ==========================================================================
   Details Info
   ========================================================================== */

.htns-cell-groups-wrapper .details-compact-info {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 0.85rem;
  color: var(--dark-gray, #333333);
}

.htns-cell-groups-wrapper .details-compact-info span {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.htns-cell-groups-wrapper .details-compact-info i {
  color: var(--secondary-color, #ed920e);
  font-size: 0.9rem;
  flex-shrink: 0;
}

/* ==========================================================================
   Empty State
   ========================================================================== */

.htns-cell-groups-empty {
  padding: 40px;
  text-align: center;
  background: var(--bg-light, #f9f9f9);
  border-radius: 8px;
  color: var(--dark-gray, #333333);
}

/* ==========================================================================
   Responsive Styles
   ========================================================================== */

/* Tablet */
@media screen and (max-width: 992px) {
  .htns-cell-groups-wrapper.cell-groups-wrapper {
    grid-template-columns: 35% 65%;
    gap: 15px;
  }
  
  .htns-cell-groups-wrapper .cell-groups-list {
    max-height: 380px;
  }
  
  .htns-cell-groups-wrapper .map-container {
    height: 320px;
  }
}

/* Mobile */
@media screen and (max-width: 768px) {
  .htns-cell-groups-wrapper.cell-groups-wrapper {
    grid-template-columns: 1fr;
    gap: 20px;
  }
  
  .htns-cell-groups-wrapper .cell-groups-list {
    max-height: 300px;
    padding-right: 4px;
  }
  
  .htns-cell-groups-wrapper .cell-group-card {
    padding: 8px 10px;
  }
  
  .htns-cell-groups-wrapper .cell-group-icon {
    width: 34px;
    height: 34px;
    font-size: 0.9rem;
  }
  
  .htns-cell-groups-wrapper .cell-group-name {
    font-size: 0.9rem;
  }
  
  .htns-cell-groups-wrapper .cell-group-address {
    font-size: 0.75rem;
  }
  
  .htns-cell-groups-wrapper .cell-group-btn {
    width: 28px;
    height: 28px;
    font-size: 0.8rem;
  }
  
  .htns-cell-groups-wrapper .cell-groups-map-wrapper {
    position: relative;
    top: 0;
  }
  
  /* Map responsive height cho tablet */
  .htns-cell-groups-wrapper .cell-groups-map {
    height: 350px;
    min-height: 250px;
  }
  
  .htns-cell-groups-wrapper .map-container {
    border-radius: 8px;
  }
  
  .htns-cell-groups-wrapper .details-title i {
    width: 32px;
    height: 32px;
    font-size: 0.9rem;
  }
  
  .htns-cell-groups-wrapper .details-title h4 {
    font-size: 0.9rem;
  }
  
  .htns-cell-groups-wrapper .btn-icon {
    width: 32px;
    height: 32px;
    font-size: 0.85rem;
  }
  
  .htns-cell-groups-wrapper .details-compact-info {
    font-size: 0.8rem;
    gap: 10px;
  }
}

/* Small Mobile */
@media screen and (max-width: 480px) {
  .htns-cell-groups-wrapper .cell-groups-list {
    max-height: 250px;
  }
  
  .htns-cell-groups-wrapper .cell-group-card {
    gap: 8px;
  }
  
  .htns-cell-groups-wrapper .cell-group-icon {
    width: 32px;
    height: 32px;
    font-size: 0.85rem;
  }
  
  /* Map responsive height cho mobile */
  .htns-cell-groups-wrapper .cell-groups-map {
    height: 280px;
    min-height: 200px;
  }
  
  .htns-cell-groups-wrapper .map-container {
    border-radius: 6px;
  }
  
  .htns-cell-groups-wrapper .cell-group-details-compact {
    padding: 12px;
  }
  
  .htns-cell-groups-wrapper .details-compact-info {
    flex-direction: column;
    gap: 8px;
  }
}

/* ==========================================================================
   Elementor Compatibility
   ========================================================================== */

.elementor-widget-shortcode .htns-cell-groups-wrapper {
  width: 100%;
}

/* Override Elementor default link colors - EXCEPT cho buttons */
.elementor-widget-shortcode .htns-cell-groups-wrapper a:not(.btn-icon) {
  color: inherit;
}

.elementor-widget-shortcode .htns-cell-groups-wrapper a:not(.btn-icon):hover {
  color: inherit;
}
