/* ImagePickerField Styles */
.ipf-field { margin-bottom: 1rem; }
.ipf-field-body { display: flex; flex-direction: column; gap: 0.75rem; }
.ipf-field-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }

.ipf-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--admin-border, #e5e7eb);
  background: var(--admin-card, #fff);
  color: var(--admin-text, #111827);
  transition: all 0.15s;
}
.ipf-btn:hover { border-color: var(--admin-accent, #6366f1); color: var(--admin-accent, #6366f1); }
.ipf-btn-upload { background: var(--admin-accent, #6366f1); color: #fff; border-color: var(--admin-accent, #6366f1); }
.ipf-btn-upload:hover { opacity: 0.9; color: #fff; }
.ipf-btn-library { background: var(--admin-card, #fff); }

/* Previews */
.ipf-preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 0.75rem;
}
.ipf-preview-item {
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  aspect-ratio: 4 / 3;
  border: 2px solid var(--admin-border, #e5e7eb);
  background: #f8fafc;
}
.ipf-preview-item img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #fff;
}
.ipf-file-thumb {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #f8fafc, #eef2ff);
  color: var(--admin-accent, #6366f1);
  font-size: 1.5rem;
}
.ipf-remove-btn {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(0,0,0,0.6);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  opacity: 0;
  transition: opacity 0.15s;
}
.ipf-preview-item:hover .ipf-remove-btn,
.ipf-preview-single:hover .ipf-remove-btn { opacity: 1; }

.ipf-preview-single {
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  max-width: 320px;
  border: 2px solid var(--admin-border, #e5e7eb);
  background: #fff;
}
.ipf-preview-single img {
  width: 100%;
  height: auto;
  max-height: 320px;
  object-fit: contain;
  display: block;
}

.ipf-preview-empty {
  border: 2px dashed var(--admin-border, #e5e7eb);
  border-radius: 6px;
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--admin-text-tertiary, #9ca3af);
  font-size: 0.85rem;
}

/* Picker Modal */
.ipf-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  animation: ipfFadeIn 0.2s ease-out;
}

@keyframes ipfFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.ipf-modal {
  background: var(--admin-card, #ffffff);
  border-radius: 14px;
  width: 100%;
  max-width: 1100px;
  height: 85vh;
  max-height: 800px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 25px 60px -15px rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(255, 255, 255, 0.1);
  border: 1px solid var(--admin-border, #e2e8f0);
}

.ipf-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--admin-border, #e2e8f0);
  background: #ffffff;
  flex-shrink: 0;
}

.ipf-modal-header h3 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--admin-text, #0f172a);
}

.ipf-modal-header h3 i {
  color: var(--admin-accent, #6366f1);
}

.ipf-close-btn {
  background: transparent;
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  cursor: pointer;
  color: var(--admin-text-tertiary, #94a3b8);
  transition: all 0.15s;
}

.ipf-close-btn:hover {
  background: #f1f5f9;
  color: #0f172a;
}

.ipf-modal-body {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.ipf-picker-sidebar {
  width: 200px;
  border-right: 1px solid var(--admin-border, #e2e8f0);
  background: #f8fafc;
  overflow-y: auto;
  padding: 0.75rem;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.ipf-folder-item {
  padding: 0.6rem 0.85rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--admin-text-secondary, #64748b);
  transition: all 0.15s ease;
}

.ipf-folder-item:hover {
  background: #e2e8f0;
  color: var(--admin-text, #0f172a);
}

.ipf-folder-item.ipf-folder-active {
  background: var(--admin-accent, #6366f1);
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.25);
}

.ipf-picker-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  background: #ffffff;
}

.ipf-picker-toolbar {
  display: flex;
  gap: 0.75rem;
  padding: 0.85rem 1.25rem;
  border-bottom: 1px solid var(--admin-border, #e2e8f0);
  align-items: center;
  background: #ffffff;
  flex-shrink: 0;
}

.ipf-picker-search {
  flex: 1;
  position: relative;
}

.ipf-picker-search i {
  position: absolute;
  left: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--admin-text-tertiary, #94a3b8);
  font-size: 0.9rem;
}

.ipf-picker-search input {
  width: 100%;
  padding: 0.55rem 0.85rem 0.55rem 2.3rem;
  border: 1px solid var(--admin-border, #e2e8f0);
  border-radius: 8px;
  font-size: 0.88rem;
  background: #f8fafc;
  color: var(--admin-text, #0f172a);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.ipf-picker-search input:focus {
  border-color: var(--admin-accent, #6366f1);
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
}

.ipf-upload-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 1.1rem;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  background: var(--admin-accent, #6366f1);
  color: #ffffff;
  border: none;
  white-space: nowrap;
  transition: all 0.15s ease;
  box-shadow: 0 2px 6px rgba(99, 102, 241, 0.2);
}

.ipf-upload-btn:hover {
  background: #4f46e5;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.ipf-picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  grid-auto-rows: max-content;
  gap: 0.85rem;
  padding: 1.25rem;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  align-content: start;
}

.ipf-picker-item {
  cursor: pointer;
  border-radius: 10px;
  overflow: hidden;
  border: 2px solid var(--admin-border, #e2e8f0);
  transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
  background: #ffffff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  display: flex;
  flex-direction: column;
  position: relative;
  user-select: none;
}

.ipf-picker-item:hover {
  border-color: var(--admin-accent, #6366f1);
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1);
}

.ipf-picker-item.ipf-selected {
  border-color: var(--admin-accent, #6366f1);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.35);
}

.ipf-picker-thumb {
  width: 100%;
  height: 110px;
  min-height: 110px;
  overflow: hidden;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f1f5f9;
  border-bottom: 1px solid #f1f5f9;
}

.ipf-picker-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.25s ease;
}

.ipf-picker-item:hover .ipf-picker-thumb img {
  transform: scale(1.05);
}

.ipf-picker-failed-icon {
  display: none;
  position: absolute;
  inset: 0;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  color: #94a3b8;
  background: #f1f5f9;
}

.ipf-picker-thumb.ipf-thumb-failed .ipf-picker-failed-icon {
  display: flex;
}

.ipf-check {
  position: absolute;
  top: 6px;
  right: 6px;
  color: var(--admin-accent, #6366f1);
  background: #ffffff;
  border-radius: 50%;
  font-size: 1.25rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.ipf-picker-name {
  padding: 0.45rem 0.6rem;
  font-size: 0.72rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--admin-text-secondary, #475569);
  background: #ffffff;
  line-height: 1.2;
}

.ipf-modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1.5rem;
  border-top: 1px solid var(--admin-border, #e2e8f0);
  background: #ffffff;
  flex-shrink: 0;
}

.ipf-selected-count {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--admin-text-secondary, #64748b);
}

.ipf-picker-bulkbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.6rem 1.25rem;
  background: #eef2ff;
  border-bottom: 1px solid #e0e7ff;
  font-size: 0.85rem;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.ipf-bulk-info {
  color: #4338ca;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.ipf-btn-sm {
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
  border-radius: 6px;
}

.ipf-btn-primary-sm {
  background: var(--admin-accent, #6366f1);
  color: #fff;
  border-color: var(--admin-accent, #6366f1);
}

.ipf-upload-progress {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 1.25rem;
  background: #f8fafc;
  border-top: 1px solid #e5e7eb;
  font-size: 0.8rem;
  color: #6b7280;
  flex-shrink: 0;
}

.ipf-progress-bar {
  flex: 1;
  height: 6px;
  background: #e5e7eb;
  border-radius: 99px;
  overflow: hidden;
}

.ipf-progress-fill {
  height: 100%;
  width: 0%;
  background: var(--admin-accent, #6366f1);
  transition: width 0.3s;
}

@media (max-width: 640px) {
  .ipf-picker-sidebar { display: none; }
  .ipf-modal { max-height: 90vh; height: 90vh; }
  .ipf-picker-grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 0.6rem; padding: 0.75rem; }
  .ipf-picker-thumb { height: 90px; min-height: 90px; }
  .ipf-preview-grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
}
