.library-creator {
  max-width: 90vw;
  display: flex;
  flex-direction: column;
  max-height: 90vh;
  background: var(--card-background);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  overflow: hidden;
}

// Header
.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  background: var(--overlay-background);
  border-bottom: 1px solid var(--border-color);

  .header-content {
    display: flex;
    align-items: center;
    gap: 0.875rem;
  }

  .header-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    background: var(--primary-color);
    border-radius: 10px;

    i {
      font-size: 1.25rem;
      color: var(--primary-contrast-color);
    }
  }

  .header-text {
    h1 {
      margin: 0;
      font-size: 1.25rem;
      font-weight: 600;
      color: var(--text-color);
    }

    p {
      margin: 0.125rem 0 0;
      font-size: 0.875rem;
      color: var(--text-secondary-color);
    }
  }
}

// Body
.dialog-body {
  flex: 1;
  overflow-y: auto;
  padding: 1.75rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 2rem;

  &::-webkit-scrollbar {
    width: 6px;
  }

  &::-webkit-scrollbar-track {
    background: transparent;
  }

  &::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;

    &:hover {
      background: var(--primary-color);
    }
  }
}

// Sections
.form-section {
  .section-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-secondary-color);

    i {
      font-size: 0.9rem;
      color: var(--primary-color);
    }

    .section-badge {
      display: flex;
      align-items: center;
      justify-content: center;
      min-width: 20px;
      height: 20px;
      padding: 0 0.375rem;
      background: var(--primary-color);
      color: var(--primary-contrast-color);
      border-radius: 10px;
      font-size: 0.7rem;
      font-weight: 600;
    }
  }
}

// Form Fields
.form-row {
  display: flex;
  gap: 1.25rem;

  &.two-col {
    .form-field {
      flex: 1;
      min-width: 0;
    }
  }

  @media (max-width: 520px) {
    flex-direction: column;
  }
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;

  label {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-color);

    .required {
      color: var(--p-red-400);
    }
  }

  .input-container {
    position: relative;

    .input-full {
      width: 100%;
      padding-right: 2.25rem;
    }

    .field-status {
      position: absolute;
      right: 0.75rem;
      top: 50%;
      transform: translateY(-50%);
      font-size: 0.9rem;

      &.success {
        color: var(--p-green-500);
      }
    }
  }
}

// Icon picker
.icon-picker-trigger {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.875rem 1rem;
  background: var(--ground-background);
  border: 1px dashed var(--border-color);
  border-radius: 8px;
  color: var(--text-secondary-color);
  font-size: 0.875rem;
  cursor: pointer;
  transition: all 0.2s ease;

  &:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
    background: var(--overlay-background);
  }

  i {
    font-size: 0.875rem;
  }
}

.icon-selected {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.625rem 0.875rem;
  background: var(--ground-background);
  border: 1px solid var(--border-color);
  border-radius: 8px;

  .icon-preview {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    background: var(--primary-color);
    border-radius: 5px;
    color: var(--primary-contrast-color);
  }

  .icon-value {
    flex: 1;
    font-size: 0.875rem;
    font-family: monospace;
    color: var(--text-color);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .icon-clear {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    background: transparent;
    border: none;
    border-radius: 4px;
    color: var(--text-secondary-color);
    cursor: pointer;
    transition: all 0.2s ease;

    &:hover {
      background: rgba(239, 68, 68, 0.15);
      color: var(--p-red-400);
    }

    i {
      font-size: 0.75rem;
    }
  }
}

.folder-structure-hint {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.625rem 0.75rem;
  background: rgba(234, 179, 8, 0.08);
  border: 1px solid rgba(234, 179, 8, 0.25);
  border-radius: 6px;
  font-size: 0.8125rem;
  color: var(--text-secondary-color);
  line-height: 1.5;

  i {
    font-size: 0.9rem;
    color: rgb(234, 179, 8);
    flex-shrink: 0;
  }

  a {
    color: var(--p-primary-color);
    text-decoration: none;
    font-weight: 500;

    &:hover {
      text-decoration: underline;
    }
  }
}

// Folders zone
.folders-zone {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1.25rem;
  background: var(--ground-background);
  border: 1px solid var(--border-color);
  border-radius: 8px;
}

.add-folder-trigger {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.875rem;
  background: transparent;
  border: 1px dashed var(--border-color);
  border-radius: 6px;
  color: var(--primary-color);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;

  &:hover {
    background: var(--overlay-background);
    border-color: var(--primary-color);
  }

  i {
    font-size: 1rem;
  }
}

.folders-list {
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
  max-height: 180px;
  overflow-y: auto;

  &::-webkit-scrollbar {
    width: 4px;
  }

  &::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 2px;
  }
}

.folder-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 0.875rem;
  background: var(--card-background);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  transition: all 0.2s ease;

  &:hover {
    border-color: var(--primary-color);

    .folder-info i {
      color: var(--primary-color);
    }
  }

  .folder-info {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;

    i {
      font-size: 0.875rem;
      color: var(--text-secondary-color);
      flex-shrink: 0;
      transition: color 0.2s ease;
    }

    .folder-path {
      font-size: 0.875rem;
      color: var(--text-color);
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
  }

  .folder-remove {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    background: transparent;
    border: none;
    border-radius: 4px;
    color: var(--text-secondary-color);
    cursor: pointer;
    opacity: 0.6;
    transition: all 0.2s ease;

    &:hover {
      opacity: 1;
      background: rgba(239, 68, 68, 0.15);
      color: var(--p-red-400);
    }

    i {
      font-size: 0.6875rem;
    }
  }
}

.empty-hint {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 1rem;
  color: var(--text-secondary-color);
  font-size: 0.875rem;

  i {
    font-size: 0.9rem;
    opacity: 0.7;
  }
}

// Options section
.options-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1rem 1.25rem;
  background: var(--ground-background);
  border: 1px solid var(--border-color);
  border-radius: 8px;
}

.option-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;

  p-toggleswitch {
    --p-toggleswitch-checked-background: var(--p-green-500);
    --p-toggleswitch-checked-hover-background: var(--p-green-600);
  }

  &.option-row-stacked {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.625rem;
  }
}

.option-divider {
  height: 1px;
  background: var(--border-color);
  margin: 0.25rem 0;
}

.option-label {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-color);

  .info-icon {
    font-size: 0.8rem;
    color: var(--text-secondary-color);
    opacity: 0.6;
    cursor: help;
    transition: opacity 0.2s ease;

    &:hover {
      opacity: 1;
      color: var(--primary-color);
    }
  }
}

// Allowed formats
.allow-all-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;

  .allow-all-label {
    font-size: 0.875rem;
    color: var(--text-color);
    cursor: pointer;
  }
}

.format-checkboxes {
  display: flex;
  flex-wrap: wrap;
  gap: 0.625rem 1.25rem;
  padding: 0.875rem;
  background: var(--card-background);
  border: 1px solid var(--border-color);
  border-radius: 6px;
}

.format-checkbox-item {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  min-width: 90px;

  .format-checkbox-label {
    font-size: 0.875rem;
    color: var(--text-color);
    cursor: pointer;
  }

  .warning-icon {
    font-size: 0.75rem;
    color: var(--p-orange-400);
    margin-left: 0.125rem;
  }

  &.has-warning {
    .format-checkbox-label {
      color: var(--p-orange-400);
    }
  }
}

::ng-deep .metadata-source-select {
  min-width: 150px;
}

.format-warning-message {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.625rem 0.75rem;
  background: rgba(234, 179, 8, 0.1);
  border: 1px solid var(--p-orange-400);
  border-radius: 6px;
  font-size: 0.75rem;
  color: var(--p-orange-400);

  i {
    flex-shrink: 0;
    font-size: 0.8rem;
  }
}

// Format chips
.format-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  width: 100%;
}

.format-chip {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.625rem;
  background: var(--card-background);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  cursor: grab;
  transition: all 0.2s ease;

  &:hover {
    border-color: var(--primary-color);
  }

  .chip-rank {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    background: var(--primary-color);
    color: var(--primary-contrast-color);
    border-radius: 50%;
    font-size: 0.625rem;
    font-weight: 600;
  }

  .chip-label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-color);
  }

  .drag-indicator {
    font-size: 0.75rem;
    color: var(--text-secondary-color);
    opacity: 0.5;
    cursor: grab;

    &:hover {
      opacity: 1;
      color: var(--primary-color);
    }
  }
}

.cdk-drag-preview {
  box-sizing: border-box;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
  background: var(--overlay-background);
  border: 1px solid var(--primary-color);
}

.cdk-drag-placeholder {
  opacity: 0.3;
}

.cdk-drag-animating {
  transition: transform 150ms cubic-bezier(0, 0, 0.2, 1);
}

// Footer
.dialog-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.5rem;
  background: var(--overlay-background);
  border-top: 1px solid var(--border-color);
}

.validation-status {
  flex: 1;
  min-width: 0;

  .status-message {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.875rem;
    font-weight: 500;

    i {
      font-size: 0.9rem;
    }

    &.warning {
      color: var(--p-orange-400);
    }

    &.ready {
      color: var(--p-green-500);
    }
  }
}

.footer-actions {
  display: flex;
  gap: 0.75rem;
  flex-shrink: 0;
}

// Responsive
@media (max-width: 520px) {
  .library-creator {
    width: 100%;
    max-width: 100%;
    border-radius: 0;
    max-height: 100vh;
  }

  .dialog-header {
    padding: 1rem;

    .header-icon {
      width: 36px;
      height: 36px;

      i {
        font-size: 1rem;
      }
    }

    .header-text h1 {
      font-size: 1rem;
    }
  }

  .dialog-body {
    padding: 1.5rem;
    gap: 1.75rem;
  }

  .dialog-footer {
    flex-direction: column;
    padding: 1rem;
    gap: 0.75rem;

    .validation-status {
      width: 100%;
    }

    .footer-actions {
      width: 100%;
      justify-content: flex-end;
    }
  }

}
