.icon-picker {
  display: flex;
  flex-direction: column;
  height: 80dvh;
  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);
  flex-shrink: 0;

  .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: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;

  ::ng-deep {
    .p-tabs {
      display: flex;
      flex-direction: column;
      height: 100%;
    }

    .p-tablist {
      background: var(--overlay-background);
      border-bottom: 1px solid var(--border-color);
      padding: 0 1rem;
    }

    .p-tab {
      display: flex;
      align-items: center;
      gap: 0.5rem;
      padding: 0.875rem 1rem;
      font-size: 0.875rem;
      font-weight: 500;

      i {
        font-size: 0.9rem;
      }
    }

    .p-tabpanels {
      flex: 1;
      overflow: hidden;
      min-height: 0;
    }

    .p-tabpanel {
      height: 100%;
      padding: 0;
    }
  }
}

// Tab content
.tab-content {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 1.25rem 1.5rem;
  overflow-y: auto;
  gap: 1.25rem;

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

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

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

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

// Search
.search-container {
  position: relative;
  flex-shrink: 0;

  .search-icon {
    position: absolute;
    left: 0.875rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.9rem;
    color: var(--text-secondary-color);
    pointer-events: none;
    z-index: 1;
  }

  .search-input {
    width: 100%;
    padding: 0.75rem 1rem 0.75rem 2.5rem;
  }
}

// Icon grid
.icon-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(44px, 1fr));
  gap: 0.5rem;
  flex: 1;
  align-content: start;
}

.icon-item {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  background: var(--ground-background);
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s ease;

  > i {
    font-size: 1.25rem;
    color: var(--text-color);
    transition: color 0.15s ease;
  }

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

    > i {
      color: var(--primary-color);
    }
  }

  &.selected {
    border-color: var(--primary-color);
    background: rgba(var(--primary-color-rgb, 59, 130, 246), 0.1);

    > i {
      color: var(--primary-color);
    }
  }

  &.svg-icon-item {
    .svg-icon-inline {
      display: flex;
      align-items: center;
      justify-content: center;
      width: 24px;
      height: 24px;

      ::ng-deep svg {
        width: 100%;
        height: 100%;
      }
    }
  }
}

// States
.loading-state,
.error-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 3rem;
  color: var(--text-secondary-color);
  font-size: 0.9rem;

  i {
    font-size: 1.5rem;
  }
}

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

// Trash zone
.trash-zone-container {
  position: sticky;
  bottom: 0;
  padding-top: 1rem;
  margin-top: auto;
}

.trash-zone {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.625rem;
  padding: 0.875rem 1.25rem;
  background: var(--ground-background);
  border: 2px dashed var(--border-color);
  border-radius: 8px;
  color: var(--text-secondary-color);
  font-size: 0.875rem;
  transition: all 0.2s ease;

  i {
    font-size: 1rem;
    color: var(--p-red-400);
  }

  &.active {
    border-color: var(--p-red-400);
    background: rgba(239, 68, 68, 0.08);
    color: var(--p-red-400);
  }
}

// Form sections
.form-section {
  background: var(--ground-background);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 1.25rem;

  .section-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
    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;
    }

    .section-actions {
      margin-left: auto;
    }
  }

  &.queue-section {
    margin-top: 1rem;
  }
}

// Form fields
.form-fields {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

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

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

  .input-full {
    width: 100%;
    padding: 0.75rem 1rem;
  }

  .code-textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', monospace;
    font-size: 0.875rem;
    resize: vertical;
    line-height: 1.5;
  }
}

// Preview
.preview-card {
  background: var(--card-background);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  overflow: hidden;

  .preview-label {
    padding: 0.5rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-secondary-color);
    background: var(--overlay-background);
    border-bottom: 1px solid var(--border-color);
  }

  .preview-content {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    min-height: 120px;

    ::ng-deep svg {
      max-width: 100%;
      max-height: 100px;
      width: auto;
      height: auto;
    }
  }
}

// Error message
.error-message {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.2);
  border-radius: 6px;
  color: var(--p-red-400);
  font-size: 0.875rem;
  font-weight: 500;

  i {
    font-size: 0.9rem;
  }
}

// Form actions
.form-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-color);
}

// Queue grid
.queue-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 0.75rem;
  max-height: 280px;
  overflow-y: auto;
  padding: 0.25rem;

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

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

.queue-item {
  background: var(--card-background);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  overflow: hidden;
  transition: all 0.2s ease;

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

  &.has-error {
    border-color: var(--p-red-400);
  }

  .queue-item-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 0.625rem;
    background: var(--overlay-background);
    border-bottom: 1px solid var(--border-color);
  }

  .queue-item-name {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-color);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .queue-item-remove {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    background: transparent;
    border: none;
    border-radius: 4px;
    color: var(--text-secondary-color);
    cursor: pointer;
    transition: all 0.15s ease;

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

    i {
      font-size: 0.625rem;
    }
  }

  .queue-item-preview {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem;
    min-height: 60px;

    ::ng-deep svg {
      max-width: 48px;
      max-height: 48px;
      width: auto;
      height: auto;
    }
  }

  .queue-item-error {
    padding: 0.5rem 0.625rem;
    font-size: 0.6875rem;
    color: var(--p-red-400);
    background: rgba(239, 68, 68, 0.08);
    border-top: 1px solid rgba(239, 68, 68, 0.15);
  }
}

// Responsive
@media (max-width: 520px) {
  .icon-picker {
    border-radius: 0;
    height: 100dvh;
  }

  .dialog-header {
    padding: 1rem;

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

      i {
        font-size: 1rem;
      }
    }

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

  .tab-content {
    padding: 1rem;
  }

  .icon-grid {
    grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
    gap: 0.375rem;
  }

  .icon-item {
    width: 40px;
    height: 40px;
  }

  .queue-grid {
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  }
}
