.photo-upload-widget {
  margin-top: 8px;
}

.photo-upload-dropzone {
  border: 2px dashed #c6cfdf;
  border-radius: 12px;
  min-height: 150px;
  padding: 20px;
  background: #f8faff;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.photo-upload-widget.is-drag-over .photo-upload-dropzone {
  border-color: #4a7bd1;
  background: #eef4ff;
  box-shadow: 0 0 0 3px rgba(74, 123, 209, 0.15);
}

.photo-upload-dropzone-text {
  margin: 0;
  color: #2f3237;
  font-weight: 600;
}

.photo-upload-dropzone-hint {
  margin: 8px 0 0 0;
  color: #4b5568;
  font-size: 13px;
}

.photo-upload-select {
  margin-top: 12px;
  border: 0;
  border-radius: 6px;
  padding: 8px 14px;
  color: #fff;
  background: #2f6fde;
  font-weight: 600;
  min-height: 34px;
}

.photo-upload-count {
  margin-top: 8px;
  color: #6b7280;
  font-size: 13px;
}

.photo-upload-reorder-hint {
  margin-top: 6px;
  color: #6b7280;
  font-size: 12px;
}

.photo-upload-error {
  display: none;
  margin-top: 8px;
  color: #b42318;
  background: #fef3f2;
  border: 1px solid #fecdca;
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 13px;
}

.photo-upload-existing-grid,
.photo-upload-grid {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.photo-upload-item {
  position: relative;
  width: 120px;
  height: 120px;
  flex: 0 0 120px;
  border: 1px solid #d7dde8;
  border-radius: 8px;
  overflow: hidden;
  background: #f3f5f9;
}

.photo-upload-item-sortable {
  cursor: grab;
  touch-action: none;
  -webkit-touch-callout: none;
  user-select: none;
  -webkit-user-select: none;
}

.photo-upload-item-sortable:hover .photo-upload-drag-handle,
.photo-upload-item-sortable.is-primary .photo-upload-drag-handle {
  opacity: 1;
}

.photo-upload-item-sortable.is-dragging {
  opacity: 0.55;
  cursor: grabbing;
}

.photo-upload-item.is-primary {
  border-color: #2f6fde;
  box-shadow: 0 0 0 2px rgba(47, 111, 222, 0.18);
}

.photo-upload-item.is-primary::after {
  content: "Hlavní foto";
  position: absolute;
  left: 6px;
  bottom: 6px;
  background: rgba(20, 24, 31, 0.82);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  padding: 5px 7px;
  border-radius: 999px;
  pointer-events: none;
}

.photo-upload-drag-handle {
  position: absolute;
  left: 6px;
  top: 6px;
  z-index: 2;
  background: rgba(20, 24, 31, 0.78);
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  line-height: 1;
  min-width: 28px;
  min-height: 28px;
  padding: 6px;
  border-radius: 999px;
  pointer-events: none;
  opacity: 0.88;
  transition: opacity 0.18s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.photo-upload-drag-handle > span {
  display: block;
  line-height: 1;
  transform: translateY(-2px);
}

.photo-upload-image {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  pointer-events: none;
  -webkit-user-drag: none;
}

.photo-upload-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #6b7280;
  font-size: 12px;
  text-align: center;
  padding: 8px;
}

.photo-upload-item.is-loading .photo-upload-placeholder:before {
  content: "";
  width: 18px;
  height: 18px;
  border: 2px solid #c6cfdf;
  border-top-color: #2f6fde;
  border-radius: 50%;
  animation: photo-upload-spin 0.7s linear infinite;
  margin-right: 6px;
}

.photo-upload-remove {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: rgba(24, 24, 24, 0.82);
  color: #fff;
  font-size: 17px;
  line-height: 1;
  font-weight: 700;
  font-family: Arial, Helvetica, sans-serif;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.photo-upload-remove:hover {
  background: rgba(24, 24, 24, 0.92);
}

.photo-upload-input {
  position: absolute !important;
  left: -9999px !important;
  width: 1px !important;
  height: 1px !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

[data-theme="dark"] .photo-upload-dropzone {
  background: #2c3039;
  border-color: #3d424b;
  box-shadow: none;
}

[data-theme="dark"] .photo-upload-widget.is-drag-over .photo-upload-dropzone {
  background: #2c3039;
  border-color: #4a7bc7;
  box-shadow: 0 0 0 3px rgba(74, 123, 199, 0.18);
}

[data-theme="dark"] .photo-upload-dropzone-text {
  color: #e8eaed;
}

[data-theme="dark"] .photo-upload-dropzone-hint,
[data-theme="dark"] .photo-upload-count,
[data-theme="dark"] .photo-upload-reorder-hint {
  color: #9aa0a8;
}

[data-theme="dark"] .photo-upload-item.is-primary {
  border-color: #4a7bc7;
  box-shadow: 0 0 0 2px rgba(74, 123, 199, 0.22);
}

[data-theme="dark"] .photo-upload-item.is-primary::after {
  background: rgba(15, 23, 42, 0.82);
}

[data-theme="dark"] .photo-upload-drag-handle {
  background: rgba(15, 23, 42, 0.82);
}

@keyframes photo-upload-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@media (max-width: 768px) {
  .photo-upload-item {
    width: 100px;
    height: 100px;
    flex-basis: 100px;
  }
}

@media (max-width: 480px) {
  .photo-upload-item {
    width: 88px;
    height: 88px;
    flex-basis: 88px;
  }
}

.photo-upload-widget.has-existing .photo-upload-dropzone {
  display: none;
}

.photo-upload-add-tile {
  width: 120px;
  height: 120px;
  flex: 0 0 120px;
  border: 2px dashed #bbb;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fafafa;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.photo-upload-add-tile:hover {
  border-color: #4caf50;
  background: #f0faf0;
}

.photo-upload-add-btn {
  width: 100%;
  height: 100%;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 28px;
  color: #aaa;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s;
}

.photo-upload-add-tile:hover .photo-upload-add-btn {
  color: #4caf50;
}

[data-theme="dark"] .photo-upload-add-tile {
  border-color: #444;
  background: #2c3039;
}

[data-theme="dark"] .photo-upload-add-tile:hover {
  border-color: #4caf50;
  background: #1e2d1e;
}

[data-theme="dark"] .photo-upload-add-btn {
  color: #666;
}
