/* Gift Popup & Drawer CSS */

/* Overlays */
.kp-popup-overlay,
.kp-drawer-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  z-index: 999999;
  display: flex;
  justify-content: center;
  align-items: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.kp-popup-overlay.active,
.kp-drawer-overlay.active {
  opacity: 1;
  visibility: visible;
}

/* Containers */
.kp-popup-container {
  background: #fff;
  border-radius: var(--kp-radius, 12px);
  width: 90%;
  max-width: 800px;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  box-shadow: var(--kp-shadow, 0 10px 40px rgba(0,0,0,0.15));
  transform: translateY(20px) scale(0.95);
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.kp-popup-overlay.active .kp-popup-container {
  transform: translateY(0) scale(1);
}

.kp-drawer-container {
  background: #fff;
  width: 100%;
  max-width: 400px;
  height: 100vh;
  position: absolute;
  right: -400px;
  top: 0;
  display: flex;
  flex-direction: column;
  box-shadow: -4px 0 24px rgba(0,0,0,0.1);
  transition: right 0.4s cubic-bezier(0.19, 1, 0.22, 1);
}

.kp-drawer-overlay.active .kp-drawer-container {
  right: 0;
}

/* Close buttons */
.kp-popup-close,
.kp-drawer-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: none;
  border: none;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  color: #6b7280;
  transition: color 0.2s;
  padding: 4px;
}

.kp-drawer-close {
  position: static;
}

.kp-popup-close:hover,
.kp-drawer-close:hover {
  color: #111827;
}

/* Headers */
.kp-popup-header {
  text-align: center;
  padding: 32px 24px 24px;
  border-bottom: 1px solid #f3f4f6;
}

.kp-drawer-header-wrap {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 24px;
  border-bottom: 1px solid #f3f4f6;
}

.kp-gift-icon {
  font-size: 48px;
  display: block;
  margin-bottom: 16px;
}

.kp-popup-header h2,
.kp-drawer-header h2 {
  margin: 0 0 8px;
  font-size: 1.5rem;
  color: #111827;
}

.kp-popup-subtitle,
.kp-drawer-subtitle {
  margin: 0;
  color: #6b7280;
  font-size: 1rem;
}

/* Grids & Lists */
.kp-gifts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 24px;
  padding: 24px;
}

.kp-gifts-drawer-list {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Gift Cards */
.kp-gift-card,
.kp-gift-drawer-card {
  border: 1px solid #e5e7eb;
  border-radius: var(--kp-radius, 12px);
  padding: 16px;
  text-align: center;
  position: relative;
  transition: transform 0.2s, box-shadow 0.2s;
  background: #fff;
}

.kp-gift-drawer-card {
  display: flex;
  align-items: center;
  text-align: left;
  padding: 12px;
}

.kp-gift-card:hover,
.kp-gift-drawer-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.06);
}

.kp-gift-badge {
  position: absolute;
  top: 12px;
  right: 12px;
  background: var(--kp-primary, #7c3aed);
  color: #fff;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  z-index: 2;
}

.kp-gift-drawer-card .kp-gift-badge {
  top: 8px;
  right: 8px;
  font-size: 0.65rem;
}

.kp-gift-image {
  width: 100%;
  height: auto;
  border-radius: 8px;
  margin-bottom: 16px;
  aspect-ratio: 1;
  object-fit: cover;
}

.kp-gift-drawer-card .kp-gift-image {
  width: 80px;
  margin-bottom: 0;
  margin-right: 16px;
}

.kp-gift-info {
  flex: 1;
}

.kp-gift-name {
  margin: 0 0 8px;
  font-size: 1.1rem;
  color: #111827;
  font-weight: 600;
}

.kp-gift-drawer-card .kp-gift-name {
  font-size: 1rem;
  margin-bottom: 4px;
}

.kp-gift-price {
  margin-bottom: 12px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
}

.kp-gift-drawer-card .kp-gift-price {
  justify-content: flex-start;
  margin-bottom: 8px;
}

.kp-original-price {
  text-decoration: line-through;
  color: #9ca3af;
  font-size: 0.9rem;
}

.kp-free-price {
  color: var(--kp-success, #10b981);
  font-weight: 700;
}

.kp-gift-stock {
  font-size: 0.8rem;
  margin-bottom: 16px;
}

.kp-in-stock { color: var(--kp-success, #10b981); }
.kp-out-stock { color: var(--kp-danger, #ef4444); }

.kp-select-gift-btn {
  width: 100%;
  background: var(--kp-primary, #7c3aed);
  color: #fff;
  border: none;
  padding: 10px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  transition: background 0.2s;
}

.kp-select-gift-btn:hover:not(:disabled) {
  background: var(--kp-primary-light, #8b5cf6);
}

.kp-select-gift-btn:disabled {
  background: #d1d5db;
  cursor: not-allowed;
}

.kp-gift-drawer-card .kp-select-gift-btn {
  padding: 8px 12px;
  font-size: 0.9rem;
}

/* Animations */
@keyframes kp-spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.kp-btn-loading {
  position: relative;
  color: transparent !important;
}

.kp-btn-loading::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 16px;
  height: 16px;
  margin: -8px 0 0 -8px;
  border: 2px solid rgba(255,255,255,0.3);
  border-radius: 50%;
  border-top-color: #fff;
  animation: kp-spin 0.8s linear infinite;
}

/* Responsive */
@media (max-width: 640px) {
  .kp-gifts-grid {
    grid-template-columns: 1fr;
  }
}
