/**
 * popup-modern-3d-final.css - Modern 3D Popup & Dropdown Form Styles
 * Phong cách: Hiện đại, tối giản, 3D glassmorphism, smooth animations
 */

/* ============================================================ */
/* === POPUP MODERN 3D WRAPPER === */
/* ============================================================ */

.skyland-popup-modern-3d {
  position: relative;
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* === POPUP HEADER === */
.skyland-popup-modern-3d .popup-header {
  padding: 16px 16px 12px 16px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.popup-header-top {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: space-between;
}

.popup-title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: #1a202c;
  flex: 1;
  word-break: break-word;
}

.popup-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 6px;
  background: linear-gradient(135deg, #0ea5e9 0%, #0369a1 100%);
  color: white;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

/* === POPUP QUICK INFO === */
.skyland-popup-modern-3d .popup-quick-info {
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.info-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 13px;
  line-height: 1.4;
}

.info-label {
  flex-shrink: 0;
  font-weight: 600;
  color: #64748b;
  min-width: 80px;
}

.info-value {
  color: #0f172a;
  word-break: break-word;
  flex: 1;
}

/* === POPUP ACTIONS === */
.skyland-popup-modern-3d .popup-actions {
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.popup-btn {
  padding: 10px 14px;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
  text-align: center;
  outline: none;
}

.popup-btn-primary {
  background: linear-gradient(135deg, #0ea5e9 0%, #0369a1 100%);
  color: white;
  box-shadow: 0 4px 12px rgba(6, 182, 212, 0.3);
}

.popup-btn-primary:active {
  transform: scale(0.98);
  box-shadow: 0 2px 6px rgba(6, 182, 212, 0.2);
}

.popup-btn-secondary {
  background: #f1f5f9;
  color: #0f172a;
  border: 1px solid #cbd5e1;
}

.popup-btn-secondary:hover {
  background: #e2e8f0;
}

.popup-btn-secondary:active {
  transform: scale(0.98);
}

/* ============================================================ */
/* === VALUATION DROPDOWN FORM === */
/* ============================================================ */

.valuation-dropdown-form {
  padding: 16px;
  background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 0 0 12px 12px;
  animation: slideDown 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.valuation-dropdown-form.hidden {
  display: none;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Form Wrapper */
.valuation-dropdown-form .form-wrapper {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.form-header {
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.form-title {
  margin: 0 0 4px 0;
  font-size: 14px;
  font-weight: 700;
  color: #0f172a;
}

.form-header small {
  display: block;
  font-size: 12px;
  color: #64748b;
  font-weight: 500;
}

/* Form Groups */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-label {
  font-size: 12px;
  font-weight: 600;
  color: #334155;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.form-input,
.form-select,
.form-textarea {
  padding: 8px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 12px;
  font-family: inherit;
  background: white;
  color: #0f172a;
  transition: all 0.2s ease;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: #0ea5e9;
  box-shadow: 0 0 0 2px rgba(14, 165, 233, 0.1);
}

.form-textarea {
  resize: vertical;
  min-height: 60px;
  line-height: 1.4;
}

/* Row 2 (side-by-side) */
.form-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.form-row-2 .form-select {
  grid-column: 1;
}

.form-row-2 .form-input {
  grid-column: 2;
}

/* Form Actions */
.form-actions {
  display: flex;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
}

.btn {
  flex: 1;
  padding: 8px 12px;
  border: none;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
  outline: none;
}

.btn-save {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: white;
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
}

.btn-save:active {
  transform: scale(0.98);
  box-shadow: 0 1px 4px rgba(16, 185, 129, 0.2);
}

.btn-cancel {
  background: #f1f5f9;
  color: #0f172a;
  border: 1px solid #cbd5e1;
}

.btn-cancel:hover {
  background: #e2e8f0;
}

.btn-cancel:active {
  transform: scale(0.98);
}

/* ============================================================ */
/* === MAPLIBRE POPUP WRAPPER MODERN 3D === */
/* ============================================================ */

.skyland-popup-modern-3d-container {
  z-index: 22 !important;
}

.skyland-popup-modern-3d-container .maplibregl-popup-content {
  padding: 0 !important;
  min-width: 0;
  width: 320px;
  max-width: min(320px, calc(100vw - 32px));
  max-height: min(56vh, 460px);
  overflow-y: auto;
  overflow-x: hidden;
  
  /* Modern 3D styling */
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.98) 0%, rgba(248, 250, 252, 0.96) 100%);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  
  /* 3D shadow effect */
  box-shadow: 
    0 0 0 1px rgba(0, 0, 0, 0.06),
    0 2px 4px rgba(0, 0, 0, 0.04),
    0 8px 16px rgba(0, 0, 0, 0.1),
    0 20px 40px rgba(0, 0, 0, 0.15);
  
  /* Smooth transitions */
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.maplibregl-popup-close-button,
.mapboxgl-popup-close-button,
.leaflet-popup-close-button,
.skyland-popup-modern-3d-container .maplibregl-popup-close-button,
.skyland-popup-modern-3d-container .mapboxgl-popup-close-button,
.skyland-popup-modern-3d-container .leaflet-popup-close-button {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
  pointer-events: none !important;
  width: 0 !important;
  height: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  font-size: 0 !important;
  overflow: hidden !important;
  border: 0 !important;
}

.skyland-v63-popup,
.skyland-popup-modern-3d,
.skyland-popup-modern-3d-container .maplibregl-popup-content {
  position: relative;
}

.skyland-popup-close {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 8;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: #eef2f6;
  color: #334155;
  font-size: 20px;
  line-height: 28px;
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.12);
}

.skyland-priority-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  min-width: 0;
  align-items: center;
}

.skyland-priority-badge {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  padding: 2px 8px;
  border-radius: 999px;
  background: #ecfeff;
  color: #0f766e;
  font-size: 11px;
  font-weight: 800;
  line-height: 1.4;
}

.skyland-priority-badge[data-priority-direct="doc"],
.skyland-priority-doc {
  background: #fff7ed;
  color: #c2410c;
  border: 1px solid #fdba74;
}

.skyland-priority-badge[data-priority-direct="doc"].is-off {
  background: #fff;
  color: #9a3412;
  opacity: 0.62;
  border-style: dashed;
}

.skyland-priority-badge[data-priority-direct="doc"].is-on {
  opacity: 1;
  border-style: solid;
  background: #ffedd5;
}

.skyland-priority-badge[data-priority-direct="doc"].is-admin-edit {
  cursor: pointer;
  min-height: 28px;
  padding: 4px 10px;
  user-select: none;
}

.skyland-priority-option.is-doc-locked {
  opacity: 0.4;
  pointer-events: none;
}

@media (max-width: 699px) {
  .skyland-priority-badge[data-priority-direct="doc"].is-admin-edit {
    min-height: 36px;
    padding: 8px 12px;
    font-size: 13px;
  }
}

@media (max-width: 699px) {
  .skyland-popup-close {
    top: 8px;
    right: 8px;
    width: 32px;
    height: 32px;
    font-size: 22px;
    line-height: 32px;
  }
}

.skyland-popup-modern-3d-container .maplibregl-popup-anchor-bottom .maplibregl-popup-content {
  margin-top: 8px;
}

/* ============================================================ */
/* === SCROLLBAR STYLING === */
/* ============================================================ */

.skyland-popup-modern-3d-container .maplibregl-popup-content::-webkit-scrollbar {
  width: 6px;
}

.skyland-popup-modern-3d-container .maplibregl-popup-content::-webkit-scrollbar-track {
  background: transparent;
}

.skyland-popup-modern-3d-container .maplibregl-popup-content::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 3px;
  transition: all 0.2s ease;
}

.skyland-popup-modern-3d-container .maplibregl-popup-content::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.3);
}

/* ============================================================ */
/* === RESPONSIVE === */
/* ============================================================ */

@media (max-width: 480px) {
  .skyland-popup-modern-3d-container .maplibregl-popup-content {
    min-width: 280px;
    max-width: 100vw;
    margin: 0 8px;
  }

  .popup-header {
    padding: 12px 14px;
  }

  .popup-title {
    font-size: 14px;
  }

  .popup-badge {
    font-size: 11px;
    padding: 3px 8px;
  }

  .popup-quick-info {
    padding: 10px 14px;
  }

  .info-row {
    font-size: 12px;
  }

  .info-label {
    min-width: 70px;
  }

  .popup-actions {
    padding: 10px 14px;
  }

  .popup-btn {
    font-size: 12px;
    padding: 9px 12px;
  }

  .valuation-dropdown-form {
    padding: 12px;
  }

  .form-row-2 {
    grid-template-columns: 1fr 1fr;
  }
}

/* SP phụ: danh sách tóm tắt lô cùng chủ (popup bản đồ + modal) */
#custSpPhuModal .spx3-card:not(.is-open) {
  cursor: pointer;
}
#custSpPhuModal .spx3-card:not(.is-open) .spx3-head {
  align-items: flex-start;
}
#custSpPhuModal .spx3-title small,
.skyland-v63-popup .spx3-title small {
  white-space: normal;
  line-height: 1.35;
}
#custSpPhuModal .spx3-hist-sec {
  margin-top: 12px;
}
#custSpPhuModal .spx3-hist {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 180px;
  overflow: auto;
  margin-bottom: 8px;
}
#custSpPhuModal .spx3-hist-item {
  padding: 8px 10px;
  border-radius: 10px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  font-size: 13px;
}
#custSpPhuModal .spx3-hist-empty {
  font-size: 12.5px;
  color: #64748b;
  margin-bottom: 8px;
}
@media (max-width: 699px) {
  #custSpPhuModal .spx3-title small {
    font-size: 12px;
  }
}

/* ============================================================ */
/* === QUYỀN HẠN & HIỂN THỊ GIÁ THU, GIÁ BÁN, PHÍ & HOA HỒNG === */
/* === TỐI ƯU ĐỒNG BỘ CẢ TRÊN ĐIỆN THOẠI & MÁY TÍNH === */
/* ============================================================ */

/* Nổi bật nhãn giá bán và giá thu */
.skyland-v63-info-grid .skyland-v63-info-item.skyland-v63-sale {
  background: rgba(8, 127, 140, 0.06);
  border-radius: 8px;
  padding: 6px 10px;
  border: 1px solid rgba(8, 127, 140, 0.18);
  transition: all 0.2s ease;
}

.skyland-v63-info-grid .skyland-v63-info-item.skyland-v63-sale .skyland-v63-info-label {
  font-weight: 700;
  color: #0d9488;
}

.skyland-v63-info-grid .skyland-v63-info-item.skyland-v63-sale .skyland-v63-info-value {
  color: #0f766e;
  font-weight: 800;
  font-size: 13.5px;
}

/* Phòng thủ CSS: Ẩn triệt để phí hoa hồng đối với khách hàng */
body.is-customer .skyland-fee-row,
body.is-customer [data-field-type="fee"],
body[data-role="customer"] .skyland-fee-row,
body[data-role="customer"] [data-field-type="fee"],
body[data-role="khach"] .skyland-fee-row,
body[data-role="khach"] [data-field-type="fee"] {
  display: none !important;
}

/* Responsive tối ưu trên màn hình điện thoại */
@media (max-width: 699px) {
  .skyland-v63-popup {
    padding: 10px;
    font-size: 13px;
  }

  .skyland-v63-info-grid {
    grid-template-columns: 1fr 1fr;
    gap: 6px;
  }

  .skyland-v63-info-grid .skyland-v63-info-item.skyland-v63-sale {
    padding: 5px 8px;
  }

  .skyland-v63-info-grid .skyland-v63-info-item.skyland-v63-sale .skyland-v63-info-value {
    font-size: 13px;
  }

  .skyland-v63-actions .popup-link {
    padding: 8px 12px;
    font-size: 12.5px;
  }
}
