@use '../../../../shared/styles/panel-shared' as panel;

.create-user-dialog {
  display: flex;
  flex-direction: column;

  @media (max-width: 768px) {
    width: 100%;
    max-width: 100%;
  }
}

.panel-header {
  @include panel.panel-header;
}

.form-container {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  padding: 2rem;
  background: var(--card-background);
  border: 1px solid var(--border-color);
  border-top: none;
  overflow-y: auto;
  max-height: 60vh;

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

  &::-webkit-scrollbar-track {
    background: var(--overlay-background);
    border-radius: 3px;
  }

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

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

  @media (max-width: 480px) {
    padding: 1rem;
    gap: 1.25rem;
  }
}

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

  .section-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0 0 0.75rem 0;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-color);
    padding-bottom: 0.5rem;

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

  &.basic-info-section {
    .form-fields-grid {
      display: grid;
      grid-template-columns: repeat(2, 1fr);
      gap: 1rem;

      .field-full {
        grid-column: 1 / -1;
      }

      .password-grid {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
      }

      @media (max-width: 640px) {
        grid-template-columns: 1fr;

        .password-grid {
          grid-template-columns: 1fr;
        }
      }
    }
  }
}

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

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

  .field-input {
    width: 100%;
  }

  .field-error {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    color: #ef4444;
    font-size: 0.875rem;
    margin-top: -0.25rem;

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

.permissions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 0.75rem;

  @media (max-width: 640px) {
    grid-template-columns: 1fr;
  }
}

.permissions-container {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;

  @media (max-width: 768px) {
    grid-template-columns: 1fr;
  }
}

.permission-group {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1rem;
  border: 1px solid var(--border-color);
  border-radius: 8px;

  .permission-group-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-color);
    margin: 0 0 0.5rem 0;
    text-transform: uppercase;
    letter-spacing: 0.025em;

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

  .permission-group-items {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
  }

  &.full-width {
    grid-column: 1 / -1;
  }
}

.permission-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.95rem;
  background: var(--ground-background);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  transition: all 0.3s ease;
  cursor: pointer;

  &:hover {
    border-color: var(--primary-color);
    transform: translateX(3px);
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.1);

    .permission-icon {
      color: var(--primary-color);
      transform: scale(1.08);
    }
  }

  &.admin-permission {
    background: rgba(255, 152, 0, 0.05);

    &:hover {
      border-color: #ff9800;

      .permission-icon {
        color: #ff9800;
      }
    }

    .permission-icon-wrapper.admin-icon {
      background: rgba(255, 152, 0, 0.1);

      .permission-icon {
        color: #ff9800;
      }
    }

    .admin-name {
      color: #ff9800;
      font-weight: 600;
    }
  }

  .permission-label {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    min-width: 0;

    .permission-icon-wrapper {
      display: flex;
      align-items: center;
      justify-content: center;
      width: 36px;
      height: 36px;
      background: var(--overlay-background);
      border-radius: 8px;
      flex-shrink: 0;

      .permission-icon {
        font-size: 1rem;
        color: var(--text-secondary-color);
        transition: all 0.3s ease;
      }
    }

    .permission-name {
      font-size: 0.9rem;
      color: var(--text-color);
      font-weight: 500;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
  }

  @media (max-width: 480px) {
    padding: 0.75rem;
    gap: 0.625rem;

    .permission-label {
      gap: 0.625rem;

      .permission-icon-wrapper {
        width: 32px;
        height: 32px;

        .permission-icon {
          font-size: 0.9rem;
        }
      }

      .permission-name {
        font-size: 0.85rem;
      }
    }
  }
}

.dialog-footer {
  @include panel.dialog-footer;
  border-top: none;

  .footer-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-secondary-color);

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

  @media (max-width: 640px) {
    .footer-info {
      justify-content: center;
    }
  }
}
