.category-tabs {
  display: flex;
  justify-content: center;
  margin-bottom: 30px;
  gap: 10px;
}

.tab-btn {
  padding: 15px 30px;
  background: white;
  border: 2px solid var(--light-red);
  color: var(--primary-red);
  cursor: pointer;
  border-radius: 25px;
  font-weight: 600;
  font-size: 1rem;
  transition: all 0.3s ease;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.tab-btn:hover {
  background: var(--light-red);
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(212, 0, 26, 0.2);
}

.tab-btn.active {
  background: var(--primary-red);
  color: white;
  border-color: var(--primary-red);
}

.loading {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 200px;
  font-size: 1.2rem;
  color: var(--primary-red);
}

.loading i {
  margin-right: 10px;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

.services-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 25px;
  margin-top: 30px;
}

.service-card {
  background: white;
  border-radius: 15px;
  padding: 25px;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
  border: 2px solid transparent;
}

.service-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 15px 40px rgba(0, 0, 0, 0.15);
  border-color: var(--primary-red);
}

.service-card.pinned {
  border: 2px solid var(--accent-gold);
  background: linear-gradient(135deg, #fff9e6 0%, white 100%);
}

.service-card.pinned::before {
  content: "⭐";
  position: absolute;
  top: 15px;
  right: 15px;
  font-size: 1.2rem;
  color: var(--accent-gold);
}

.service-header {
  display: flex;
  align-items: center;
  margin-bottom: 20px;
}

.service-icon {
  width: 60px;
  height: 60px;
  border-radius: 12px;
  margin-right: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--light-red);
  color: var(--primary-red);
  font-size: 1.5rem;
  font-weight: bold;
}

.service-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 12px;
}

.service-info h3 {
  color: var(--dark-gray);
  font-size: 1.3rem;
  font-weight: 600;
  margin-bottom: 5px;
}

.service-info .company-id {
  color: var(--primary-red);
  font-size: 0.9rem;
  font-weight: 500;
  opacity: 0.8;
}

.percentages {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 15px;
  margin: 20px 0;
}

.percentage-item {
  background: var(--light-gray);
  padding: 12px;
  border-radius: 10px;
  text-align: center;
  border-left: 4px solid var(--primary-red);
}

.percentage-item .label {
  font-size: 0.8rem;
  color: var(--dark-gray);
  opacity: 0.7;
  text-transform: uppercase;
  font-weight: 600;
  margin-bottom: 5px;
}

.percentage-item .value {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--primary-red);
}

.service-action {
  margin-top: 20px;
}

.select-btn {
  width: 100%;
  padding: 15px;
  background: linear-gradient(
    135deg,
    var(--primary-red) 0%,
    var(--dark-red) 100%
  );
  color: white;
  border: none;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.select-btn:hover {
  background: linear-gradient(
    135deg,
    var(--dark-red) 0%,
    var(--primary-red) 100%
  );
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(212, 0, 26, 0.3);
}

.error-message {
  background: #ffe6e6;
  color: #d32f2f;
  padding: 20px;
  border-radius: 10px;
  text-align: center;
  margin: 20px 0;
  border: 2px solid #ffcdd2;
}

.no-results {
  text-align: center;
  padding: 60px 20px;
  background: white;
  border-radius: 15px;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
}

.no-results i {
  font-size: 4rem;
  color: var(--primary-red);
  margin-bottom: 20px;
  opacity: 0.5;
}

.no-results h3 {
  color: var(--dark-gray);
  margin-bottom: 10px;
  font-size: 1.5rem;
}

.no-results p {
  color: var(--dark-gray);
  opacity: 0.7;
}

/* Modal Styles */
.modal {
  display: none;
  position: fixed;
  z-index: 1050;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(5px);
}

.modal.show {
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-content {
  background: white;
  margin: 20px;
  padding: 0;
  border-radius: 20px;
  width: 95%;
  max-width: 800px; /* เพิ่มขนาดเป็น XL */
  max-height: 90vh;
  overflow: hidden;
  box-shadow: 0 25px 80px rgba(0, 0, 0, 0.4);
  animation: modalSlideIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  display: flex;
  flex-direction: column;
}

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: translateY(-100px) scale(0.8);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.modal-header {
  background: linear-gradient(
    135deg,
    var(--primary-red) 0%,
    var(--dark-red) 100%
  );
  color: white;
  padding: 25px;
  position: relative;
  text-align: center;
}

.modal-header h2 {
  margin: 0;
  font-size: 1.4rem;
  font-weight: 600;
  margin-bottom: 5px;
}

.modal-header p {
  margin: 0;
  opacity: 0.9;
  font-size: 0.9rem;
}

.close-btn {
  position: absolute;
  right: 20px;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  font-size: 1.3rem;
  cursor: pointer;
  width: 35px;
  height: 35px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
}

.close-btn:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: translateY(-50%) scale(1.1);
}

.modal-body {
  padding: 30px;
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

.modal-footer {
  padding: 25px 30px;
  background: white;
  border-top: 1px solid #e0e0e0;
  border-radius: 0 0 20px 20px;
  position: sticky;
  bottom: 0;
  z-index: 10;
}

.modal-footer .confirm-btn {
  width: 100%;
  padding: 18px;
  background: linear-gradient(135deg, var(--success-green) 0%, #00a832 100%);
  color: white;
  border: none;
  border-radius: 15px;
  font-size: 1.2rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  opacity: 0.5;
  pointer-events: none;
  box-shadow: 0 8px 25px rgba(0, 208, 69, 0.3);
}

.modal-footer .confirm-btn.enabled {
  opacity: 1;
  pointer-events: auto;
}

.modal-footer .confirm-btn.enabled:hover {
  background: linear-gradient(135deg, #00a832 0%, var(--success-green) 100%);
  transform: translateY(-3px);
  box-shadow: 0 12px 35px rgba(0, 208, 69, 0.4);
}

.phone-input-section {
  margin-bottom: 30px;
}

.phone-input-section h3 {
  color: var(--dark-gray);
  margin-bottom: 15px;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  gap: 10px;
}

.phone-input {
  width: 100%;
  padding: 15px;
  border: 2px solid #e0e0e0;
  border-radius: 12px;
  font-size: 1rem;
  transition: all 0.3s ease;
  background: white;
}

.phone-input:focus {
  outline: none;
  border-color: var(--primary-red);
  box-shadow: 0 0 0 3px rgba(212, 0, 26, 0.1);
}

.phone-input.error {
  border-color: #d32f2f;
  background: #fff5f5;
}

.error-text {
  color: #d32f2f;
  font-size: 0.85rem;
  margin-top: 5px;
  display: none;
}

.amounts-section h3 {
  color: var(--dark-gray);
  margin-bottom: 20px;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  gap: 10px;
}

.amounts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 25px;
}

.amount-item {
  background: var(--light-gray);
  padding: 15px 10px;
  border-radius: 12px;
  border: 2px solid transparent;
  cursor: pointer;
  transition: all 0.3s ease;
  text-align: center;
  position: relative;
  min-height: 80px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.amount-item:hover {
  border-color: var(--primary-red);
  background: var(--light-red);
  transform: translateY(-2px);
}

.amount-item.selected {
  border-color: var(--primary-red);
  background: var(--primary-red);
  color: white;
}

.amount-item .amount {
  font-weight: 700;
  font-size: 1rem;
  margin-bottom: 5px;
  color: var(--primary-red);
}

.amount-item.selected .amount {
  color: white;
}

.amount-item .description {
  font-size: 0.75rem;
  opacity: 0.8;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
}

.confirm-section {
  border-top: 1px solid #e0e0e0;
  padding-top: 25px;
  margin-top: 20px;
}

.confirm-btn {
  width: 100%;
  padding: 15px;
  background: linear-gradient(135deg, var(--success-green) 0%, #00a832 100%);
  color: white;
  border: none;
  border-radius: 12px;
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  opacity: 0.5;
  pointer-events: none;
}

.confirm-btn.enabled {
  opacity: 1;
  pointer-events: auto;
}

.confirm-btn.enabled:hover {
  background: linear-gradient(135deg, #00a832 0%, var(--success-green) 100%);
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(0, 208, 69, 0.3);
}

.modal-loading {
  text-align: center;
  padding: 40px;
  color: var(--primary-red);
}

.modal-loading i {
  font-size: 2.5rem;
  margin-bottom: 15px;
  animation: spin 1s linear infinite;
}

.modal-error {
  text-align: center;
  padding: 40px;
  color: #d32f2f;
}

.modal-error i {
  font-size: 2.5rem;
  margin-bottom: 15px;
}

/* SweetAlert2 Custom Styles */
.swal-confirm-btn {
  font-weight: 600 !important;
  padding: 10px 20px !important;
  border-radius: 8px !important;
}

.swal-cancel-btn {
  font-weight: 600 !important;
  padding: 10px 20px !important;
  border-radius: 8px !important;
}

@media (max-width: 768px) {
  .container {
    padding: 15px;
  }

  .header h1 {
    font-size: 2rem;
  }

  .category-tabs {
    flex-direction: column;
    align-items: center;
  }

  .tab-btn {
    width: 100%;
    max-width: 300px;
  }

  .services-grid {
    grid-template-columns: 1fr;
    gap: 20px;
  }

  .percentages {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .modal-content {
    margin: 10px;
    width: calc(100% - 20px);
    max-height: 95vh;
    max-width: 95vw;
  }

  .modal-header {
    padding: 20px;
  }

  .modal-body {
    padding: 20px 20px 130px 20px;
  }

  .amounts-grid {
    grid-template-columns: 1fr; /* 1 คอลัมน์สำหรับมือถือ */
    gap: 12px;
  }

  .amount-item {
    min-height: 70px;
    padding: 12px;
  }

  .amount-item .amount {
    font-size: 1rem;
  }

  .amount-item .description {
    font-size: 0.75rem;
    -webkit-line-clamp: 2;
  }

  .floating-confirm {
    padding: 15px 20px 25px 20px;
  }

  .floating-confirm .confirm-btn {
    padding: 16px;
    font-size: 1.1rem;
  }
}
