/**
 * @file
 * NodeHive DAM styles using Gin theme CSS variables.
 */

.dam-wrapper {
  max-width: 100%;
}

/* Layout with sidebar */
.dam-layout {
  display: flex;
  gap: var(--gin-spacing-l, 2rem);
}

/* Folder Sidebar */
.dam-sidebar {
  width: 220px;
  flex-shrink: 0;
}

.dam-sidebar__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--gin-spacing-s, 0.75rem);
}

.dam-sidebar__title {
  font-size: var(--gin-font-size-m, 1rem);
  font-weight: var(--gin-font-weight-semibold, 600);
  color: var(--gin-color-text, #222330);
  margin: 0;
}

.dam-sidebar__add {
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid var(--gin-border-color, #d4d4d8);
  border-radius: var(--gin-border-radius-s, 4px);
  background: var(--gin-bg-layer, #fff);
  color: var(--gin-color-text, #222330);
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.dam-sidebar__add:hover {
  background: var(--gin-color-primary, #003cc5);
  border-color: var(--gin-color-primary, #003cc5);
  color: #fff;
}

.dam-folders {
  list-style: none;
  margin: 0;
  padding: 0;
  border: 1px solid var(--gin-border-color-layer, #e5e5e5);
  border-radius: var(--gin-border-radius, 8px);
  background: var(--gin-bg-layer, #fff);
  overflow: hidden;
}

.dam-folders__item {
  border-bottom: 1px solid var(--gin-border-color-layer, #e5e5e5);
}

.dam-folders__item:last-child {
  border-bottom: none;
}

.dam-folders__btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: var(--gin-spacing-xs, 0.5rem);
  padding: var(--gin-spacing-s, 0.75rem) var(--gin-spacing-m, 1rem);
  background: none;
  border: none;
  cursor: pointer;
  text-align: left;
  font-size: var(--gin-font-size-s, 0.875rem);
  color: var(--gin-color-text, #222330);
  transition: background 0.2s ease;
}

.dam-folders__btn:hover {
  background: var(--gin-bg-layer2, #f8f9fa);
}

.dam-folders__item--active .dam-folders__btn {
  background: var(--gin-color-primary-light, rgba(0, 60, 197, 0.1));
  color: var(--gin-color-primary, #003cc5);
  font-weight: var(--gin-font-weight-semibold, 600);
}

.dam-folders__icon {
  flex-shrink: 0;
  font-size: 1rem;
}

.dam-folders__name {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dam-folders__item {
  position: relative;
}

.dam-folders__edit {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  width: 24px;
  height: 24px;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 12px;
  opacity: 0;
  transition: opacity 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--gin-border-radius-s, 4px);
}

.dam-folders__item:hover .dam-folders__edit {
  opacity: 1;
}

.dam-folders__edit:hover {
  background: var(--gin-bg-layer2, #f8f9fa);
}

/* Folder Edit Modal */
.dam-folder-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
}

.dam-folder-modal.is-open {
  display: flex;
}

.dam-folder-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
}

.dam-folder-modal__content {
  position: relative;
  background: var(--gin-bg-layer, #fff);
  border-radius: var(--gin-border-radius-l, 12px);
  box-shadow: var(--gin-shadow-xl, 0 20px 40px rgba(0, 0, 0, 0.3));
  width: 400px;
  max-width: 90vw;
}

.dam-folder-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--gin-spacing-m, 1rem) var(--gin-spacing-l, 1.5rem);
  border-bottom: 1px solid var(--gin-border-color-layer, #e5e5e5);
}

.dam-folder-modal__title {
  margin: 0;
  font-size: var(--gin-font-size-l, 1.125rem);
  font-weight: var(--gin-font-weight-semibold, 600);
}

.dam-folder-modal__close {
  width: 28px;
  height: 28px;
  padding: 0;
  border: none;
  background: var(--gin-bg-layer2, #f8f9fa);
  border-radius: 50%;
  font-size: 1.25rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gin-color-text-light, #6b7280);
}

.dam-folder-modal__close:hover {
  background: var(--gin-color-danger, #d32f2f);
  color: #fff;
}

.dam-folder-modal__body {
  padding: var(--gin-spacing-l, 1.5rem);
}

.dam-folder-modal__field {
  margin-bottom: var(--gin-spacing-m, 1rem);
}

.dam-folder-modal__field:last-child {
  margin-bottom: 0;
}

.dam-folder-modal__label {
  display: block;
  font-size: var(--gin-font-size-s, 0.875rem);
  font-weight: var(--gin-font-weight-semibold, 600);
  color: var(--gin-color-text-light, #6b7280);
  margin-bottom: var(--gin-spacing-xs, 0.5rem);
}

.dam-folder-modal__input,
.dam-folder-modal__select {
  width: 100%;
  padding: var(--gin-spacing-s, 0.75rem);
  border: 1px solid var(--gin-border-color, #d4d4d8);
  border-radius: var(--gin-border-radius, 8px);
  font-size: var(--gin-font-size-m, 1rem);
  background: var(--gin-bg-layer, #fff);
}

.dam-folder-modal__input:focus,
.dam-folder-modal__select:focus {
  outline: none;
  border-color: var(--gin-color-primary, #003cc5);
  box-shadow: 0 0 0 2px var(--gin-color-primary-light, rgba(0, 60, 197, 0.1));
}

.dam-folder-modal__footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--gin-spacing-s, 0.75rem);
  padding: var(--gin-spacing-m, 1rem) var(--gin-spacing-l, 1.5rem);
  border-top: 1px solid var(--gin-border-color-layer, #e5e5e5);
}

.dam-folder-modal__cancel,
.dam-folder-modal__save {
  padding: var(--gin-spacing-s, 0.75rem) var(--gin-spacing-l, 1.5rem);
  border-radius: var(--gin-border-radius, 8px);
  font-size: var(--gin-font-size-s, 0.875rem);
  font-weight: var(--gin-font-weight-semibold, 600);
  cursor: pointer;
  transition: all 0.2s ease;
}

.dam-folder-modal__cancel {
  background: none;
  border: 1px solid var(--gin-border-color, #d4d4d8);
  color: var(--gin-color-text, #222330);
}

.dam-folder-modal__cancel:hover {
  background: var(--gin-bg-layer2, #f8f9fa);
}

.dam-folder-modal__save {
  background: var(--gin-color-primary, #003cc5);
  border: none;
  color: #fff;
}

.dam-folder-modal__save:hover {
  background: var(--gin-color-primary-hover, #002a8a);
}

.dam-folder-modal__save:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

/* Folder dropzone state */
.dam-folders__item.is-dragover .dam-folders__btn {
  background: var(--gin-color-primary-light, rgba(0, 60, 197, 0.15));
  outline: 2px dashed var(--gin-color-primary, #003cc5);
  outline-offset: -2px;
}

.dam-folders__item.is-drop-success .dam-folders__btn {
  background: var(--gin-color-success-light, rgba(46, 125, 50, 0.15));
}

/* Collection dropzone state */
.dam-collections__item.is-dragover .dam-collections__btn {
  background: var(--gin-color-primary-light, rgba(0, 60, 197, 0.15));
  outline: 2px dashed var(--gin-color-primary, #003cc5);
  outline-offset: -2px;
}

.dam-collections__item.is-drop-success .dam-collections__btn {
  background: var(--gin-color-success-light, rgba(46, 125, 50, 0.15));
}

/* Collections Section */
.dam-sidebar__header--collections {
  margin-top: var(--gin-spacing-l, 1.5rem);
}

.dam-collections {
  list-style: none;
  margin: 0;
  padding: 0;
  border: 1px solid var(--gin-border-color-layer, #e5e5e5);
  border-radius: var(--gin-border-radius, 8px);
  background: var(--gin-bg-layer, #fff);
  overflow: hidden;
}

.dam-collections__item {
  position: relative;
  border-bottom: 1px solid var(--gin-border-color-layer, #e5e5e5);
}

.dam-collections__item:last-child {
  border-bottom: none;
}

.dam-collections__btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: var(--gin-spacing-xs, 0.5rem);
  padding: var(--gin-spacing-s, 0.75rem) var(--gin-spacing-m, 1rem);
  background: none;
  border: none;
  cursor: pointer;
  text-align: left;
  font-size: var(--gin-font-size-s, 0.875rem);
  color: var(--gin-color-text, #222330);
  transition: background 0.2s ease;
}

.dam-collections__btn:hover {
  background: var(--gin-bg-layer2, #f8f9fa);
}

.dam-collections__item--active .dam-collections__btn {
  background: var(--gin-color-primary-light, rgba(0, 60, 197, 0.1));
  color: var(--gin-color-primary, #003cc5);
  font-weight: var(--gin-font-weight-semibold, 600);
}

.dam-collections__icon {
  flex-shrink: 0;
  font-size: 1rem;
}

.dam-collections__name {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dam-collections__edit {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  width: 24px;
  height: 24px;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 12px;
  opacity: 0;
  transition: opacity 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--gin-border-radius-s, 4px);
}

.dam-collections__item:hover .dam-collections__edit {
  opacity: 1;
}

.dam-collections__edit:hover {
  background: var(--gin-bg-layer2, #f8f9fa);
}

.dam-collections__empty {
  padding: var(--gin-spacing-s, 0.75rem) var(--gin-spacing-m, 1rem);
  font-size: var(--gin-font-size-s, 0.875rem);
  color: var(--gin-color-text-light, #6b7280);
  font-style: italic;
}

/* Collection Modal - reuses folder modal styles */
.dam-collection-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
}

.dam-collection-modal.is-open {
  display: flex;
}

.dam-collection-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
}

.dam-collection-modal__content {
  position: relative;
  background: var(--gin-bg-layer, #fff);
  border-radius: var(--gin-border-radius-l, 12px);
  box-shadow: var(--gin-shadow-xl, 0 20px 40px rgba(0, 0, 0, 0.3));
  width: 400px;
  max-width: 90vw;
}

.dam-collection-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--gin-spacing-m, 1rem) var(--gin-spacing-l, 1.5rem);
  border-bottom: 1px solid var(--gin-border-color-layer, #e5e5e5);
}

.dam-collection-modal__title {
  margin: 0;
  font-size: var(--gin-font-size-l, 1.125rem);
  font-weight: var(--gin-font-weight-semibold, 600);
}

.dam-collection-modal__close {
  width: 28px;
  height: 28px;
  padding: 0;
  border: none;
  background: var(--gin-bg-layer2, #f8f9fa);
  border-radius: 50%;
  font-size: 1.25rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gin-color-text-light, #6b7280);
}

.dam-collection-modal__close:hover {
  background: var(--gin-color-danger, #d32f2f);
  color: #fff;
}

.dam-collection-modal__body {
  padding: var(--gin-spacing-l, 1.5rem);
}

.dam-collection-modal__field {
  margin-bottom: var(--gin-spacing-m, 1rem);
}

.dam-collection-modal__field:last-child {
  margin-bottom: 0;
}

.dam-collection-modal__label {
  display: block;
  font-size: var(--gin-font-size-s, 0.875rem);
  font-weight: var(--gin-font-weight-semibold, 600);
  color: var(--gin-color-text-light, #6b7280);
  margin-bottom: var(--gin-spacing-xs, 0.5rem);
}

.dam-collection-modal__input {
  width: 100%;
  padding: var(--gin-spacing-s, 0.75rem);
  border: 1px solid var(--gin-border-color, #d4d4d8);
  border-radius: var(--gin-border-radius, 8px);
  font-size: var(--gin-font-size-m, 1rem);
  background: var(--gin-bg-layer, #fff);
}

.dam-collection-modal__input:focus {
  outline: none;
  border-color: var(--gin-color-primary, #003cc5);
  box-shadow: 0 0 0 2px var(--gin-color-primary-light, rgba(0, 60, 197, 0.1));
}

.dam-collection-modal__footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--gin-spacing-m, 1rem) var(--gin-spacing-l, 1.5rem);
  border-top: 1px solid var(--gin-border-color-layer, #e5e5e5);
}

.dam-collection-modal__footer-right {
  display: flex;
  gap: var(--gin-spacing-s, 0.75rem);
}

.dam-collection-modal__delete {
  padding: var(--gin-spacing-s, 0.75rem) var(--gin-spacing-l, 1.5rem);
  border-radius: var(--gin-border-radius, 8px);
  font-size: var(--gin-font-size-s, 0.875rem);
  font-weight: var(--gin-font-weight-semibold, 600);
  cursor: pointer;
  transition: all 0.2s ease;
  background: var(--gin-color-danger, #d32f2f);
  border: none;
  color: #fff;
}

.dam-collection-modal__delete:hover {
  background: #b71c1c;
}

.dam-collection-modal__delete:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

.dam-collection-modal__cancel,
.dam-collection-modal__save {
  padding: var(--gin-spacing-s, 0.75rem) var(--gin-spacing-l, 1.5rem);
  border-radius: var(--gin-border-radius, 8px);
  font-size: var(--gin-font-size-s, 0.875rem);
  font-weight: var(--gin-font-weight-semibold, 600);
  cursor: pointer;
  transition: all 0.2s ease;
}

.dam-collection-modal__cancel {
  background: none;
  border: 1px solid var(--gin-border-color, #d4d4d8);
  color: var(--gin-color-text, #222330);
}

.dam-collection-modal__cancel:hover {
  background: var(--gin-bg-layer2, #f8f9fa);
}

.dam-collection-modal__save {
  background: var(--gin-color-primary, #003cc5);
  border: none;
  color: #fff;
}

.dam-collection-modal__save:hover {
  background: var(--gin-color-primary-hover, #002a8a);
}

.dam-collection-modal__save:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

/* New folder form */
.dam-sidebar__new-folder {
  margin-top: var(--gin-spacing-s, 0.75rem);
  padding: var(--gin-spacing-s, 0.75rem);
  background: var(--gin-bg-layer, #fff);
  border: 1px solid var(--gin-border-color-layer, #e5e5e5);
  border-radius: var(--gin-border-radius, 8px);
}

.dam-sidebar__new-folder-input {
  width: 100%;
  padding: var(--gin-spacing-xs, 0.5rem) var(--gin-spacing-s, 0.75rem);
  border: 1px solid var(--gin-border-color, #d4d4d8);
  border-radius: var(--gin-border-radius, 8px);
  font-size: var(--gin-font-size-s, 0.875rem);
  margin-bottom: var(--gin-spacing-xs, 0.5rem);
}

.dam-sidebar__new-folder-input:focus {
  outline: none;
  border-color: var(--gin-color-primary, #003cc5);
  box-shadow: 0 0 0 2px var(--gin-color-primary-light, rgba(0, 60, 197, 0.1));
}

.dam-sidebar__new-folder-save,
.dam-sidebar__new-folder-cancel {
  padding: var(--gin-spacing-xs, 0.5rem) var(--gin-spacing-s, 0.75rem);
  font-size: var(--gin-font-size-xs, 0.75rem);
  font-weight: var(--gin-font-weight-semibold, 600);
  border-radius: var(--gin-border-radius-s, 4px);
  cursor: pointer;
  transition: all 0.2s ease;
}

.dam-sidebar__new-folder-save {
  background: var(--gin-color-primary, #003cc5);
  color: #fff;
  border: none;
  margin-right: var(--gin-spacing-xs, 0.5rem);
}

.dam-sidebar__new-folder-save:hover {
  background: var(--gin-color-primary-hover, #002a8a);
}

.dam-sidebar__new-folder-cancel {
  background: none;
  border: 1px solid var(--gin-border-color, #d4d4d8);
  color: var(--gin-color-text, #222330);
}

.dam-sidebar__new-folder-cancel:hover {
  background: var(--gin-bg-layer2, #f8f9fa);
}

/* Main content area */
.dam-main {
  flex: 1;
  min-width: 0;
}

/* Sidebar upload zone variant */
.dam-upload-zone--sidebar {
  padding: var(--gin-spacing-m, 1rem);
  margin-bottom: var(--gin-spacing-m, 1rem);
}

.dam-upload-zone--sidebar .dam-upload-zone__icon {
  margin-bottom: var(--gin-spacing-xs, 0.5rem);
}

.dam-upload-zone--sidebar .dam-upload-zone__text {
  font-size: var(--gin-font-size-s, 0.875rem);
  margin: 0;
}

.dam-upload-zone--sidebar .dam-upload-zone__hint {
  display: none;
}

.dam-header {
  margin-bottom: var(--gin-spacing-l, 2rem);
}

.dam-title {
  font-family: var(--gin-font, Inter, sans-serif);
  font-size: var(--gin-font-size-h1, 1.75rem);
  font-weight: var(--gin-font-weight-bold, 700);
  color: var(--gin-color-text, #222330);
  margin: 0;
}

/* Upload Zone */
.dam-upload-zone {
  position: relative;
  border: 2px dashed var(--gin-border-color-layer2, #d4d4d8);
  border-radius: var(--gin-border-radius, 8px);
  padding: var(--gin-spacing-xl, 3rem);
  text-align: center;
  margin-bottom: var(--gin-spacing-l, 2rem);
  background: var(--gin-bg-layer, #fff);
  transition: all 0.2s ease;
}

.dam-upload-zone:hover,
.dam-upload-zone.is-dragover {
  border-color: var(--gin-color-primary, #003cc5);
  background: var(--gin-bg-layer2, #f8f9fa);
}

.dam-upload-zone.is-dragover {
  transform: scale(1.01);
}

.dam-upload-zone__content {
  pointer-events: none;
}

.dam-upload-zone.is-dragover .dam-upload-zone__content {
  opacity: 0.5;
}

.dam-upload-zone__icon {
  display: block;
  margin: 0 auto var(--gin-spacing-s, 0.75rem);
  color: var(--gin-color-text-light, #6b7280);
}

.dam-upload-zone__text {
  font-size: var(--gin-font-size-m, 1rem);
  color: var(--gin-color-text, #222330);
  margin: 0 0 var(--gin-spacing-xs, 0.5rem);
}

.dam-upload-zone__button {
  background: none;
  border: none;
  color: var(--gin-color-primary, #003cc5);
  cursor: pointer;
  font-weight: var(--gin-font-weight-semibold, 600);
  text-decoration: underline;
  padding: 0;
  pointer-events: auto;
}

.dam-upload-zone__button:hover {
  color: var(--gin-color-primary-hover, #002a8a);
}

.dam-upload-zone__hint {
  font-size: var(--gin-font-size-s, 0.875rem);
  color: var(--gin-color-text-light, #6b7280);
  margin: 0;
}

.dam-upload-zone__input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.dam-upload-zone__progress {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: transparent;
  border-radius: 0 0 var(--gin-border-radius, 8px) var(--gin-border-radius, 8px);
  overflow: hidden;
}

.dam-upload-zone__progress.is-uploading::after {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--gin-color-primary, #003cc5);
  animation: progress-indeterminate 1.5s infinite ease-in-out;
}

@keyframes progress-indeterminate {
  0% {
    transform: translateX(-100%);
  }
  50% {
    transform: translateX(0);
  }
  100% {
    transform: translateX(100%);
  }
}

/* Search bar - full width above layout */
.dam-search-bar {
  padding: var(--gin-spacing-l, 1.5rem) 0;
  margin-bottom: var(--gin-spacing-m, 1rem);
}

.dam-search-group {
  display: flex;
  flex: 1;
  height: 56px;
  border: 2px solid var(--gin-border-color, #e5e7eb);
  border-radius: 12px;
  background: #fff;
  overflow: hidden;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.dam-search-group:focus-within {
  border-color: var(--gin-color-primary, #003cc5);
  box-shadow: 0 0 0 3px rgba(0, 60, 197, 0.1);
}

.dam-group-select {
  height: 100%;
  padding: 0 16px;
  padding-right: 36px;
  border: none;
  border-right: 1px solid var(--gin-border-color, #e5e7eb);
  background: transparent;
  font-size: 15px;
  font-weight: 500;
  color: var(--gin-color-text, #222330);
  cursor: pointer;
  min-width: 140px;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}

.dam-group-select:focus {
  outline: none;
  background-color: var(--gin-color-primary-light, rgba(0, 60, 197, 0.05));
}

.dam-group-select:hover {
  background-color: var(--gin-color-primary-light, rgba(0, 60, 197, 0.05));
}

.dam-search-input-wrapper {
  flex: 1;
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
}

.dam-search-icon {
  flex-shrink: 0;
  color: var(--gin-color-text-light, #9ca3af);
}

.dam-search-input {
  flex: 1;
  height: 100%;
  border: none;
  background: transparent;
  font-size: 16px;
  color: var(--gin-color-text, #222330);
}

.dam-search-input:focus {
  outline: none;
}

.dam-search-input::placeholder {
  color: var(--gin-color-text-light, #9ca3af);
}

/* Legacy filters (hidden, kept for hidden inputs) */
.dam-filters__select[type="hidden"] {
  display: none;
}

/* Grid */
.dam-grid {
  min-height: 200px;
}

.dam-grid__items {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: var(--gin-spacing-m, 1rem);
}

.dam-grid__loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--gin-spacing-xl, 3rem);
  color: var(--gin-color-text-light, #6b7280);
}

.dam-grid__spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--gin-border-color, #d4d4d8);
  border-top-color: var(--gin-color-primary, #003cc5);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: var(--gin-spacing-s, 0.75rem);
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.dam-grid__empty {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--gin-spacing-xxl, 4rem);
  color: var(--gin-color-text-light, #6b7280);
}

.dam-grid__empty svg {
  margin-bottom: var(--gin-spacing-m, 1rem);
  opacity: 0.5;
}

.dam-grid__load-more {
  display: flex;
  justify-content: center;
  padding: var(--gin-spacing-l, 2rem);
}

.dam-grid__load-more-btn {
  padding: var(--gin-spacing-s, 0.75rem) var(--gin-spacing-l, 2rem);
  background: var(--gin-color-primary, #003cc5);
  color: #fff;
  border: none;
  border-radius: var(--gin-border-radius, 8px);
  font-size: var(--gin-font-size-m, 1rem);
  font-weight: var(--gin-font-weight-semibold, 600);
  cursor: pointer;
  transition: background 0.2s ease;
}

.dam-grid__load-more-btn:hover {
  background: var(--gin-color-primary-hover, #002a8a);
}

/* Grid Item */
.dam-item {
  position: relative;
  background: var(--gin-bg-layer, #fff);
  border: 1px solid var(--gin-border-color-layer, #e5e5e5);
  border-radius: var(--gin-border-radius, 8px);
  overflow: hidden;
  transition: all 0.2s ease;
}

.dam-item:hover {
  border-color: var(--gin-color-primary, #003cc5);
  box-shadow: var(--gin-shadow-l, 0 4px 12px rgba(0, 0, 0, 0.1));
  transform: translateY(-2px);
}

.dam-item__thumbnail {
  aspect-ratio: 1;
  background: var(--gin-bg-layer2, #f8f9fa);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  cursor: pointer;
}

.dam-item__thumbnail img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.dam-item__placeholder {
  color: var(--gin-color-text-light, #6b7280);
  opacity: 0.5;
}

.dam-item__info {
  padding: var(--gin-spacing-s, 0.75rem);
  border-top: 1px solid var(--gin-border-color-layer, #e5e5e5);
}

.dam-item__name {
  display: block;
  font-size: var(--gin-font-size-s, 0.875rem);
  font-weight: var(--gin-font-weight-semibold, 600);
  color: var(--gin-color-text, #222330);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: var(--gin-spacing-xxs, 0.25rem);
}

.dam-item__meta {
  display: flex;
  justify-content: space-between;
  font-size: var(--gin-font-size-xs, 0.75rem);
  color: var(--gin-color-text-light, #6b7280);
}

.dam-item__type {
  text-transform: capitalize;
}

.dam-item__mime {
  text-transform: lowercase;
  opacity: 0.6;
}

/* HTMX loading state */
.htmx-request .dam-grid__items {
  opacity: 0.5;
  pointer-events: none;
}

/* Uploaded item animation */
.dam-item.is-new {
  animation: fadeInUp 0.3s ease;
}

/* Drag and drop for media items */
.dam-item {
  cursor: grab;
}

.dam-item.is-dragging {
  opacity: 0.5;
  cursor: grabbing;
}

.dam-item:active {
  cursor: grabbing;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Toast Notification */
.dam-toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(1rem);
  background: var(--gin-color-text, #222);
  color: #fff;
  padding: 0.75rem 1.5rem;
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 500;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  opacity: 0;
  transition: opacity 0.3s ease, transform 0.3s ease;
  z-index: 10000;
  pointer-events: none;
}

.dam-toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Preview Modal */
.dam-preview {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
}

.dam-preview.is-open {
  display: flex;
}

.dam-preview__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  animation: fadeIn 0.2s ease;
}

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

.dam-preview__content {
  position: relative;
  display: flex;
  background: var(--gin-bg-layer, #fff);
  border-radius: var(--gin-border-radius-l, 12px);
  box-shadow: var(--gin-shadow-xl, 0 20px 40px rgba(0, 0, 0, 0.3));
  width: 95vw;
  height: 90vh;
  max-width: 1600px;
  overflow: hidden;
  animation: scaleIn 0.2s ease;
}

@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.dam-preview__close {
  position: absolute;
  top: var(--gin-spacing-s, 0.75rem);
  right: var(--gin-spacing-s, 0.75rem);
  width: 32px;
  height: 32px;
  background: var(--gin-bg-layer2, #f8f9fa);
  border: none;
  border-radius: 50%;
  font-size: 1.5rem;
  line-height: 1;
  color: var(--gin-color-text-light, #6b7280);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  z-index: 10;
}

.dam-preview__close:hover {
  background: var(--gin-color-danger, #d32f2f);
  color: #fff;
}

.dam-preview__media {
  flex: 1;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--gin-bg-layer2, #f8f9fa);
  padding: var(--gin-spacing-l, 2rem);
  overflow: hidden;
}

.dam-preview__media img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: var(--gin-border-radius, 8px);
}

.dam-preview__pdf {
  width: 100%;
  height: 100%;
  min-height: 500px;
  flex: 1;
  border: none;
  border-radius: var(--gin-border-radius, 8px);
}

.dam-preview__video {
  max-width: 100%;
  max-height: 100%;
  border-radius: var(--gin-border-radius, 8px);
}

.dam-preview__audio-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 400px;
  height: 100%;
  padding: 3rem;
  background: var(--gin-bg-layer2, #f4f4f5);
  border-radius: var(--gin-border-radius, 8px);
}

.dam-preview__audio-icon {
  width: 120px;
  height: 120px;
  color: var(--gin-color-primary, #003ecc);
  opacity: 0.5;
  margin-bottom: 2.5rem;
}

.dam-preview__audio {
  width: 100%;
  height: 54px;
  border-radius: 999px;
  border: 2px solid var(--gin-color-primary, #003ecc);
  padding: 4px;
}

.dam-preview__media .dam-preview__placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--gin-color-text-light, #6b7280);
  padding: var(--gin-spacing-xl, 3rem);
}

.dam-preview__media .dam-preview__placeholder svg {
  width: 64px;
  height: 64px;
  margin-bottom: var(--gin-spacing-m, 1rem);
  opacity: 0.5;
}

.dam-preview__info {
  width: 300px;
  flex-shrink: 0;
  padding: var(--gin-spacing-l, 2rem);
  border-left: 1px solid var(--gin-border-color-layer, #e5e5e5);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.dam-preview__field {
  margin-bottom: var(--gin-spacing-m, 1rem);
}

.dam-preview__label {
  display: block;
  font-size: var(--gin-font-size-s, 0.875rem);
  font-weight: var(--gin-font-weight-semibold, 600);
  color: var(--gin-color-text-light, #6b7280);
  margin-bottom: var(--gin-spacing-xxs, 0.25rem);
}

.dam-preview__name-input,
.dam-preview__alt-input {
  width: 100%;
  padding: var(--gin-spacing-xs, 0.5rem) var(--gin-spacing-s, 0.75rem);
  border: 1px solid var(--gin-border-color, #d4d4d8);
  border-radius: var(--gin-border-radius, 8px);
  font-size: var(--gin-font-size-m, 1rem);
  background: var(--gin-bg-layer, #fff);
  color: var(--gin-color-text, #222330);
}

.dam-preview__name-input:focus,
.dam-preview__alt-input:focus {
  outline: none;
  border-color: var(--gin-color-primary, #003cc5);
  box-shadow: 0 0 0 2px var(--gin-color-primary-light, rgba(0, 60, 197, 0.1));
}

.dam-preview__save {
  width: 100%;
  padding: var(--gin-spacing-xs, 0.5rem) var(--gin-spacing-m, 1rem);
  background: var(--gin-color-primary, #003cc5);
  color: #fff;
  border: none;
  border-radius: var(--gin-border-radius, 8px);
  font-size: var(--gin-font-size-s, 0.875rem);
  font-weight: var(--gin-font-weight-semibold, 600);
  cursor: pointer;
  margin-bottom: var(--gin-spacing-m, 1rem);
  transition: background 0.2s ease;
}

.dam-preview__save:hover {
  background: var(--gin-color-primary-hover, #002a8a);
}

.dam-preview__save:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

.dam-preview__meta {
  margin: 0;
  font-size: var(--gin-font-size-s, 0.875rem);
}

.dam-preview__meta dt {
  font-weight: var(--gin-font-weight-semibold, 600);
  color: var(--gin-color-text-light, #6b7280);
  margin-bottom: var(--gin-spacing-xxs, 0.25rem);
}

.dam-preview__meta dd {
  margin: 0 0 var(--gin-spacing-m, 1rem);
  color: var(--gin-color-text, #222330);
}

.dam-preview__alt--missing {
  color: var(--gin-color-danger, #d32f2f);
  font-style: italic;
}

.dam-preview__styles {
  margin-top: var(--gin-spacing-m, 1rem);
  padding-top: var(--gin-spacing-m, 1rem);
  border-top: 1px solid var(--gin-border-color-layer, #e5e5e5);
}

.dam-preview__styles-title {
  font-size: var(--gin-font-size-s, 0.875rem);
  font-weight: var(--gin-font-weight-semibold, 600);
  color: var(--gin-color-text-light, #6b7280);
  margin: 0 0 var(--gin-spacing-s, 0.75rem);
}

.dam-preview__styles-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 200px;
  overflow-y: auto;
}

.dam-preview__style-item {
  display: flex;
  align-items: center;
  gap: var(--gin-spacing-xs, 0.5rem);
  margin-bottom: var(--gin-spacing-xs, 0.5rem);
  font-size: var(--gin-font-size-xs, 0.75rem);
}

.dam-preview__style-name {
  flex-shrink: 0;
  width: 80px;
  color: var(--gin-color-text-light, #6b7280);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dam-preview__style-url {
  flex: 1;
  min-width: 0;
  padding: 4px 6px;
  border: 1px solid var(--gin-border-color, #d4d4d8);
  border-radius: var(--gin-border-radius-s, 4px);
  font-size: var(--gin-font-size-xs, 0.75rem);
  font-family: monospace;
  background: var(--gin-bg-layer2, #f8f9fa);
  color: var(--gin-color-text, #222330);
  cursor: text;
}

.dam-preview__style-url:focus {
  outline: none;
  border-color: var(--gin-color-primary, #003cc5);
}

.dam-preview__style-copy {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid var(--gin-border-color, #d4d4d8);
  border-radius: var(--gin-border-radius-s, 4px);
  background: var(--gin-bg-layer, #fff);
  cursor: pointer;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.dam-preview__style-copy:hover {
  background: var(--gin-bg-layer2, #f8f9fa);
  border-color: var(--gin-color-primary, #003cc5);
}

.dam-preview__actions {
  margin-top: auto;
  padding-top: var(--gin-spacing-m, 1rem);
}

.dam-preview__edit {
  display: inline-block;
  padding: var(--gin-spacing-s, 0.75rem) var(--gin-spacing-l, 2rem);
  background: var(--gin-color-primary, #003cc5);
  color: #fff;
  text-decoration: none;
  border-radius: var(--gin-border-radius, 8px);
  font-weight: var(--gin-font-weight-semibold, 600);
  transition: background 0.2s ease;
}

.dam-preview__edit:hover {
  background: var(--gin-color-primary-hover, #002a8a);
  color: #fff;
}

/* Responsive preview */
@media (max-width: 768px) {
  .dam-preview__content {
    flex-direction: column;
    max-width: 95vw;
  }

  .dam-preview__media {
    min-width: auto;
    max-width: 100%;
    max-height: 50vh;
  }

  .dam-preview__info {
    width: 100%;
    border-left: none;
    border-top: 1px solid var(--gin-border-color-layer, #e5e5e5);
  }
}

/* Bulk selection checkbox */
.dam-item__checkbox {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 10;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.dam-item:hover .dam-item__checkbox,
.dam-item.is-selected .dam-item__checkbox {
  opacity: 1;
}

.dam-item__select {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.dam-item__checkmark {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  background: white;
  border: 2px solid var(--gin-border-color, #d1d5db);
  border-radius: 4px;
  transition: all 0.15s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.dam-item__checkmark::after {
  content: '';
  display: none;
  width: 5px;
  height: 10px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
  margin-bottom: 2px;
}

.dam-item__select:checked + .dam-item__checkmark {
  background: var(--gin-color-primary, #003cc5);
  border-color: var(--gin-color-primary, #003cc5);
}

.dam-item__select:checked + .dam-item__checkmark::after {
  display: block;
}

.dam-item.is-selected {
  outline: 2px solid var(--gin-color-primary, #003cc5);
  outline-offset: -2px;
}

/* Bulk action bar */
.dam-bulk-bar {
  display: none;
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  background: var(--gin-bg-layer, #fff);
  border: 1px solid var(--gin-border-color, #d1d5db);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  padding: 12px 16px;
  align-items: center;
  gap: 16px;
}

.dam-bulk-bar.is-visible {
  display: flex;
}

.dam-bulk-bar__info {
  font-size: var(--gin-font-size-s, 0.875rem);
  font-weight: 600;
  color: var(--gin-color-text, #1f2937);
  white-space: nowrap;
}

.dam-bulk-bar__actions {
  display: flex;
  gap: 8px;
}

.dam-bulk-bar__btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  font-size: var(--gin-font-size-s, 0.875rem);
  font-weight: 500;
  color: var(--gin-color-text, #1f2937);
  background: var(--gin-bg-layer2, #f8f9fa);
  border: 1px solid var(--gin-border-color, #d1d5db);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.dam-bulk-bar__btn:hover {
  background: var(--gin-bg-layer3, #e5e7eb);
  border-color: var(--gin-border-color-emphasis, #9ca3af);
}

.dam-bulk-bar__btn svg {
  flex-shrink: 0;
}

.dam-bulk-bar__btn--clear {
  background: transparent;
  border-color: transparent;
  color: var(--gin-color-text-light, #6b7280);
}

.dam-bulk-bar__btn--clear:hover {
  background: var(--gin-bg-layer2, #f8f9fa);
  color: var(--gin-color-text, #1f2937);
}

.dam-bulk-bar__btn--danger {
  background: var(--gin-color-danger, #d32f2f);
  border-color: var(--gin-color-danger, #d32f2f);
  color: #fff;
}

.dam-bulk-bar__btn--danger:hover {
  background: #b71c1c;
  border-color: #b71c1c;
}

/* Bulk move modal */
.dam-bulk-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10000;
}

.dam-bulk-modal.is-open {
  display: block;
}

.dam-bulk-modal__backdrop {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
}

.dam-bulk-modal__content {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 90%;
  max-width: 400px;
  background: var(--gin-bg-layer, #fff);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

.dam-bulk-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--gin-border-color-layer, #e5e5e5);
}

.dam-bulk-modal__title {
  margin: 0;
  font-size: var(--gin-font-size-l, 1.125rem);
  font-weight: 600;
  color: var(--gin-color-title, #111827);
}

.dam-bulk-modal__close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  font-size: 24px;
  line-height: 1;
  color: var(--gin-color-text-light, #6b7280);
  background: none;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.dam-bulk-modal__close:hover {
  background: var(--gin-bg-layer2, #f8f9fa);
  color: var(--gin-color-text, #1f2937);
}

.dam-bulk-modal__body {
  padding: 20px;
}

.dam-bulk-modal__info {
  margin: 0 0 16px;
  font-size: var(--gin-font-size-s, 0.875rem);
  color: var(--gin-color-text, #1f2937);
}

.dam-bulk-modal__select {
  width: 100%;
  padding: 10px 12px;
  font-size: var(--gin-font-size-s, 0.875rem);
  color: var(--gin-color-text, #1f2937);
  background: var(--gin-bg-layer, #fff);
  border: 1px solid var(--gin-border-color, #d1d5db);
  border-radius: 6px;
}

.dam-bulk-modal__footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 16px 20px;
  border-top: 1px solid var(--gin-border-color-layer, #e5e5e5);
}

.dam-bulk-modal__cancel {
  padding: 8px 16px;
  font-size: var(--gin-font-size-s, 0.875rem);
  color: var(--gin-color-text, #1f2937);
  background: var(--gin-bg-layer, #fff);
  border: 1px solid var(--gin-border-color, #d1d5db);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.dam-bulk-modal__cancel:hover {
  background: var(--gin-bg-layer2, #f8f9fa);
}

.dam-bulk-modal__confirm {
  padding: 8px 16px;
  font-size: var(--gin-font-size-s, 0.875rem);
  color: white;
  background: var(--gin-color-primary, #003cc5);
  border: 1px solid var(--gin-color-primary, #003cc5);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.dam-bulk-modal__confirm:hover {
  background: var(--gin-color-primary-hover, #002a8a);
}

.dam-bulk-modal__confirm:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.dam-bulk-modal__hint {
  margin: 12px 0 0;
  font-size: var(--gin-font-size-xs, 0.75rem);
  color: var(--gin-color-text-light, #6b7280);
  font-style: italic;
}

.dam-bulk-modal__new-collection {
  display: flex;
  gap: var(--gin-spacing-s, 0.75rem);
  align-items: center;
}

.dam-bulk-modal__input {
  flex: 1;
  padding: var(--gin-spacing-s, 0.75rem);
  border: 1px solid var(--gin-border-color, #d4d4d8);
  border-radius: var(--gin-border-radius, 8px);
  font-size: var(--gin-font-size-m, 1rem);
  background: var(--gin-bg-layer, #fff);
}

.dam-bulk-modal__input:focus {
  outline: none;
  border-color: var(--gin-color-primary, #003cc5);
  box-shadow: 0 0 0 2px var(--gin-color-primary-light, rgba(0, 60, 197, 0.1));
}

.dam-bulk-modal__back {
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--gin-border-color, #d4d4d8);
  border-radius: var(--gin-border-radius, 8px);
  background: var(--gin-bg-layer, #fff);
  cursor: pointer;
  font-size: 1rem;
  color: var(--gin-color-text-light, #6b7280);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.dam-bulk-modal__back:hover {
  background: var(--gin-bg-layer2, #f8f9fa);
  color: var(--gin-color-text, #222330);
}
