/* Popup Manager Layout */
.popup-manager-container {
  display: grid;
  gap: 2rem;
  grid-template-columns: 1fr;
}

@media (min-width: 1200px) {
  .popup-manager-container {
    grid-template-columns: 380px 1fr;
    align-items: start;
  }
  /* 왼쪽 사이드바처럼 고정될 영역 (이미지 라이브러리) */
  .section-assets {
    position: sticky;
    top: 2rem;
  }
}

/* Section Headers */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
  border-bottom: 2px solid #f1f5f9;
  padding-bottom: 0.75rem;
}
.section-header h3 {
  font-size: 1.1rem;
  font-weight: 700;
  color: #1e293b;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}
.popup-preview-tools {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.popup-preview-background-label {
  margin-top: -6px;
  margin-bottom: 10px;
  font-size: 12px;
  color: #64748b;
  text-align: right;
}

/* Upload Zone */
#popupDropZone {
  border: 2px dashed #cbd5e1;
  border-radius: 12px;
  padding: 2rem 1rem;
  text-align: center;
  background-color: #f8fafc;
  transition: all 0.2s ease;
  cursor: pointer;
  color: #64748b;
  font-weight: 500;
}
#popupDropZone:hover,
#popupDropZone.drag-over {
  border-color: #0d9488;
  background-color: #f0fdfa;
  color: #0f766e;
}
#popupDropZone i {
  font-size: 2rem;
  margin-bottom: 0.5rem;
  display: block;
  color: inherit;
}

/* Asset Grid (Image Gallery) */
.asset-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 12px;
  margin-top: 1rem;
  max-height: 400px;
  overflow-y: auto;
  padding-right: 4px;
}
/* Scrollbar styling for grid */
.asset-grid::-webkit-scrollbar {
  width: 6px;
}
.asset-grid::-webkit-scrollbar-track {
  background: #f1f5f9;
}
.asset-grid::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 3px;
}

.asset-card {
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  aspect-ratio: 1 / 1; /* Square thumbnails */
  border: 2px solid transparent;
  cursor: pointer;
  transition: all 0.2s;
  background: #e2e8f0;
}
.asset-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}
.asset-card.selected {
  border-color: #0d9488;
  box-shadow: 0 0 0 2px rgba(13, 148, 136, 0.2);
}
.asset-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.asset-card .check-icon {
  position: absolute;
  top: 4px;
  right: 4px;
  background: #0d9488;
  color: white;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  opacity: 0;
  transform: scale(0.8);
  transition: all 0.2s;
}
.asset-card.selected .check-icon {
  opacity: 1;
  transform: scale(1);
}
/* Hidden radio input */
.asset-card input[type="radio"] {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

/* Popup Form Styling */
.popup-form-card {
  background: white;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  border: 1px solid #e2e8f0;
  padding: 1.5rem;
}

.form-fieldset {
  margin-bottom: 2rem;
  padding-bottom: 2rem;
  border: none;
}
.form-fieldset:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
}
.form-fieldset legend {
  font-size: 0.95rem;
  font-weight: 600;
  color: #64748b;
  margin-bottom: 1rem;
  display: block;
  width: 100%;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Toggle Switch for Status */
.switch-toggle {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 20px;
}
.switch-toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}
.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #cbd5e1;
  transition: 0.4s;
  border-radius: 20px;
}
.slider:before {
  position: absolute;
  content: "";
  height: 14px;
  width: 14px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: 0.4s;
  border-radius: 50%;
}
input:checked + .slider {
  background-color: #0d9488;
}
input:checked + .slider:before {
  transform: translateX(16px);
}

/* Popup List Table Improvements */
.popup-table-row {
  background: white;
  transition: background 0.2s;
}
.popup-table-row:hover {
  background: #f8fafc;
}
.popup-preview-thumb {
  width: 80px;
  height: 50px;
  border-radius: 4px;
  object-fit: cover;
  background-color: #eee;
  border: 1px solid #e2e8f0;
}

/* Custom File Actions Bar */
.file-actions-bar {
  background: #f8fafc;
  padding: 0.75rem;
  border-radius: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 1rem;
  font-size: 0.9rem;
  color: #475569;
}

/* Popup Overlay (preview + front) */
.kono-popup-overlay {
  position: fixed;
  inset: 0;
  background: transparent;
  pointer-events: none;
  z-index: 10000;
  opacity: 0;
  visibility: hidden;
  transition:
    opacity 0.3s,
    visibility 0.3s;
}
.kono-popup-overlay.visible {
  opacity: 1;
  visibility: visible;
}
.kono-popup-backdrop {
  position: absolute;
  inset: 0;
  z-index: 0;
  display: none;
  pointer-events: none;
  overflow: hidden;
}
.kono-popup-backdrop img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
}
.popup-preview-exit-btn {
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 10003;
  border: 0;
  border-radius: 999px;
  padding: 8px 12px;
  background: rgba(17, 24, 39, 0.88);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.popup-preview-exit-btn:hover {
  background: rgba(17, 24, 39, 1);
}
.kono-popup-content {
  pointer-events: auto;
  position: fixed;
  z-index: 1;
  background: #ffffff;
  padding: 0;
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  max-width: 92vw;
  max-height: 90vh;
  overflow: hidden;
  transform: translate(0, 0) scale(1);
  transition: transform 0.3s;
}
.kono-popup-header {
  padding: 12px 16px;
  background: #ffffff;
  color: #111827;
  font-weight: 700;
  font-size: 14px;
}
.kono-popup-body {
  background: #ffffff;
}
.kono-popup-body img {
  display: block;
  max-width: 100%;
  max-height: 80vh;
}
.kono-popup-html {
  padding: 12px 16px;
  font-size: 14px;
  color: #111827;
  border-top: 1px solid #e5e7eb;
}
#popupPreviewContent {
  pointer-events: auto;
  box-shadow: 0 0 25px rgba(0, 0, 0, 0.25) !important;
}

.kono-popup-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 12px;
  background: #ffffff;
  color: #111827;
  gap: 10px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "맑은 고딕", "Malgun Gothic", sans-serif;
}
/* Empty State */
.empty-state {
  text-align: center;
  padding: 2rem;
  color: #94a3b8;
  font-size: 0.9rem;
  background: #f8fafc;
  border-radius: 8px;
  border: 1px dashed #cbd5e1;
}

/* Preview Popup Close Buttons */
.kono-popup-hide {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}
.kono-popup-hide-check {
  width: 14px;
  height: 14px;
  accent-color: #111827;
  appearance: auto;
  display: inline-block;
}
.kono-popup-close {
  color: #111827;
  font-size: 12px;
  font-weight: 600;
}
.kono-popup-hide:hover .kono-popup-close {
  text-decoration: underline;
}

.kono-popup-close-x {
  pointer-events: auto;
  background: transparent;
  border: none;
  font-size: 1.1rem;
  color: #9ca3af;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition:
    transform 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94),
    background-color 0.2s ease;
}
.kono-popup-close-x:hover {
  transform: rotate(90deg);
  background-color: #f3f4f6;
  color: #111827;
}

.kono-popup-close-btn {
  border-radius: 6px;
  background-color: #374151;
  color: white;
  border: none;
  padding: 6px 14px;
  font-size: 0.8rem;
  font-weight: 500;
  border-radius: 999px;
  cursor: pointer;
  transition:
    background-color 0.2s ease,
    transform 0.1s ease;
  line-height: 1.4;
}
.kono-popup-close-btn:hover {
  background-color: #111827;
}
.kono-popup-close-btn:active {
  transform: scale(0.95);
}

.kono-popup-footer .kono-popup-close-btn {
  border-radius: 6px !important;
}
.kono-popup-header {
  height: 36px;
  padding: 0 12px;
  display: flex;
  align-items: center;
}

/* Front popup header alignment */
.kono-popup-header {
  justify-content: space-between;
  gap: 8px;
}
.kono-popup-header-title {
  flex: 1;
  margin-right: auto;
}
.kono-popup-close-x {
  margin-left: auto;
}

.kono-popup-content.centered {
  transform: translate(-50%, -50%) scale(1);
}

/* Fixed quick menu (right side) */
.popup-float-menu {
  position: fixed;
  right: 20px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.popup-float-btn {
  background: #0f766e;
  color: #ffffff;
  border: none;
  box-shadow: 0 6px 16px rgba(15, 118, 110, 0.25);
  padding: 10px 14px;
  font-size: 0.85rem;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
}

.popup-float-btn:hover {
  background: #115e59;
  color: #ffffff;
}

@media (max-width: 1024px) {
  .popup-float-menu {
    top: auto;
    bottom: 16px;
    right: 16px;
    transform: none;
  }
}

.popup-float-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
  max-width: 220px;
}

.popup-float-item {
  width: 100%;
  background: #ffffff;
  color: #0f172a;
  border: 1px solid #e2e8f0;
  border-radius: 999px;
  padding: 8px 12px;
  text-align: left;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  box-shadow: 0 6px 12px rgba(15, 23, 42, 0.06);
}

.popup-float-item:hover {
  border-color: #0f766e;
  color: #0f766e;
}

.popup-float-item-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: inline-block;
  max-width: 160px;
  font-size: 0.85rem;
}

.popup-float-empty {
  color: #64748b;
  font-size: 0.8rem;
  padding-left: 4px;
}

.popup-float-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.popup-float-delete-form {
  margin: 0;
}

.popup-float-delete-btn {
  background: #fee2e2;
  color: #b91c1c;
  border: 1px solid #fecaca;
  border-radius: 999px;
  padding: 8px 10px;
  cursor: pointer;
  box-shadow: 0 6px 12px rgba(185, 28, 28, 0.12);
}

.popup-float-delete-btn:hover {
  background: #fecaca;
  color: #991b1b;
}

/* Mobile popup: full-width with small margin */
.kono-popup-content.kono-popup-mobile {
  width: auto;
  max-width: none;
  max-height: none;
  box-sizing: border-box;
  height: calc(100vh - 16px);
  left: 8px;
  right: 8px;
  top: 8px;
  transform: translate(0, 0);
  display: flex;
  flex-direction: column;
}

.kono-popup-content.kono-popup-mobile .kono-popup-body {
  flex: 1;
  display: flex;
}

.kono-popup-content.kono-popup-mobile .kono-popup-body a {
  display: block;
  width: 100%;
  height: 100%;
}

.kono-popup-content.kono-popup-mobile .kono-popup-body img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.kono-popup-content.kono-popup-mobile .kono-popup-header {
  padding: 0 12px;
  height: 36px;
  min-height: 36px;
  display: flex;
  align-items: center;
  font-size: 13px;
  line-height: 1;
}

.kono-popup-content.kono-popup-mobile .kono-popup-header-title {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kono-popup-content.kono-popup-mobile .kono-popup-footer {
  padding: 0 10px;
  height: 36px;
  min-height: 36px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.kono-popup-content.kono-popup-mobile .kono-popup-close-btn {
  padding: 4px 10px;
  font-size: 12px;
  line-height: 1;
}
